<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2019/1/9
 * Time: 16:01
 */

namespace App\Tools\Astrolog;

/**
 * 鉴爱相关逻辑
 * Class AuthenticateLove
 * @package App\Tools\Astrolog
 */
class AuthenticateLove
{
    /**
     * 参数配置
     * @var array
     */
    public $option = [];
    /**
     * 内置其他参数配置
     * @var array
     */
    protected $param = [];
    /**
     * 当前生成的数据
     * @var array
     */
    protected $data = [];
    /**
     * 错误信息 msg
     * @var string
     */
    protected $error = '';

    /**
     * 构造函数
     * AuthenticateLove constructor.
     * @param array $option 自定义配置
     */
    public function __construct($option = [])
    {
        // 实例化时初始化参数
        if (!empty($option))
        {
            $this->option = array_merge($this->option, $option);
        }
    }

    public function init()
    {
        // 太阳数
        $this->getSunScore($this->option['data1'][1]);
        // 月亮数
        $this->getMoonScore($this->option['data1'][1]);
        // 金星数
        $this->getVenuScore($this->option['data1'][1]);
        // 火星数
        $this->getMarsScore($this->option['data1'][1]);
        // 冲断数
        $this->getThrustScore($this->option['data1'][1]);
        // 宿命数
        $this->getDestinyScore($this->option['data1'][1]);
        // 宫位激发数
        $this->getHouseScore($this->option['data1'][1]);

        // 太阳数
        $this->getSunScore($this->option['data2'][1]);
        // 月亮数
        $this->getMoonScore($this->option['data2'][1]);
        // 金星数
        $this->getVenuScore($this->option['data2'][1]);
        // 火星数
        $this->getMarsScore($this->option['data2'][1]);
        // 冲断数
        $this->getThrustScore($this->option['data2'][1]);
        // 宿命数
        $this->getDestinyScore($this->option['data2'][1]);
        // 宫位激发数
        $this->getHouseScore($this->option['data2'][1]);
        // 合盘指数总分
        $this->data['synastryScore'] = array_sum($this->option['synastryScore']);
        // 粘合数
        $this->getGlueScore();
        // B_VS_A
        $relations1 = $this->getRelations(0);
        // A_VS_B
        $relations2 = $this->getRelations(1);

        $data = ['result1' => $this->getFinalResult($relations1), 'result2' => $this->getFinalResult($relations2)];

        return $data;
    }

    /**
     * 获取对方对于我的身份
     * @param int $i 0=> B_VS_A , 1 => A_VS_B
     * @return array 词条id-百分比,
     */
    protected function getRelations($i = 0)
    {
        // 初始化返回值
        $result = ['keywords' => [], 'scores' => []];
        // B_VS_A
        if ($i === 0)
        {
            // B_VS_A A
            $data0 = $this->option['data1'][0];
            // B_VS_A B
            $data1 = $this->option['data1'][1];
            // A_VS_B B
//            $data2 = $this->option['data2'][0];
            // A_VS_B A
            $data3 = $this->option['data2'][1];

            $nata1 = $this->option['natal_data1'];
            $nata2 = $this->option['natal_data2'];

            $sunScore1 = $this->data['sun'][0];
            $sunScore2 = $this->data['sun'][1];

            $moonScore1 = $this->data['moon'][0];
            $moonScore2 = $this->data['moon'][1];

            $venuScore1 = $this->data['venu'][0];
            $venuScore2 = $this->data['venu'][1];

            $marsScore1 = $this->data['mars'][0];
//            $marsScore2 = $this->data['mars'][1];

//            $houseScore1 = $this->data['house'][0];
            $houseScore2 = $this->data['house'][1];

            $destinyScore1 = $this->data['destiny'][0];
//            $destinyScore2 = $this->data['destiny'][1];

            $glueScore1 = $this->data['glue'][0];
//            $glueScore2 = $this->data['glue'][1];

            $thrustScore1 = $this->data['thrust'][0];
//            $thrustScore2 = $this->data['thrust'][1];

            $midPoint1 = $this->data['midPoint'][0];
            $midPoint2 = $this->data['midPoint'][1];

            $power1 = $this->data['power'][0];
            $power2 = $this->data['power'][1];

//            $recode1 = $this->option['recode1'];
            $recode2 = $this->option['recode2'];
        }// A_VS_B
        else
        {
            // B_VS_A A
            $data0 = $this->option['data2'][0];
            // B_VS_A B
            $data1 = $this->option['data2'][1];
            // A_VS_B B
//            $data2 = $this->option['data1'][0];
            // A_VS_B A
            $data3 = $this->option['data1'][1];

            $nata1 = $this->option['natal_data2'];
            $nata2 = $this->option['natal_data1'];

            $sunScore1 = $this->data['sun'][1];
            $sunScore2 = $this->data['sun'][0];
            $moonScore1 = $this->data['moon'][1];
            $moonScore2 = $this->data['moon'][0];

            $venuScore1 = $this->data['venu'][1];
            $venuScore2 = $this->data['venu'][0];

            $marsScore1 = $this->data['mars'][1];
//            $marsScore2 = $this->data['mars'][0];

//            $houseScore1 = $this->data['house'][1];
            $houseScore2 = $this->data['house'][0];

            $destinyScore1 = $this->data['destiny'][1];
//            $destinyScore2 = $this->data['destiny'][0];

            $glueScore1 = $this->data['glue'][1];
//            $glueScore2 = $this->data['glue'][0];

            $thrustScore1 = $this->data['thrust'][1];
//            $thrustScore2 = $this->data['thrust'][0];

            $midPoint1 = $this->data['midPoint'][1];
            $midPoint2 = $this->data['midPoint'][0];

            $power1 = $this->data['power'][1];
            $power2 = $this->data['power'][0];

//            $recode1 = $this->option['recode2'];
            $recode2 = $this->option['recode1'];
        }

        $yearDiff = abs($this->option['recode1']['year'] - $this->option['recode2']['year']);

        // 对方月亮对我除金木冲相外无其它刑冲
        $p1_phase_90180_num = 0;
        $p1_phase_46789_num = 0;
        if (!empty($data1['planets'][1]['phase']))
        {
            foreach ($data1['planets'][1]['phase'] as $phase)
            {
                if (in_array($phase['id'], [4, 6, 7, 8, 9]))
                {
                    $p1_phase_46789_num++;
                }
                if (in_array($phase['phase_e'], [90, 180]))
                {
                    if (!in_array($phase['id'], [3, 5]) || $phase['phase_e'] != 180)
                    {
                        $p1_phase_90180_num++;
                    }
                }
            }
        }

        // 隔膜者 3 关怀着需要判断，所以计算排前
        //	对方月刑我月，且月正数大于负数
        //		月亮负数/3*10%
        // 疏离者 4
        //	对方月刑我月亮，且月亮负数大于正数
        //		（月亮负数-正数）*10%
        if (isset($data1['planets'][1]['phase']['1-1'])
            && $data1['planets'][1]['phase']['1-1']['phase_e'] == 90)
        {
            // 隔膜者3
            if ($moonScore1['good'] > $moonScore1['bad'])
            {
                $result['keywords'][] = 3;
                $result['scores'][] = ($moonScore1['bad'] * 10 / 3);
            }// 疏离者 4
            elseif ($moonScore1['good'] < $moonScore1['bad'])
            {
                $result['keywords'][] = 4;
                $result['scores'][] = ($moonScore1['bad'] - $moonScore1['good']) * 10;
            }
        }
        // 关怀者1(抚慰者2)心灵归宿37
        //  月亮正数大于9且大于月亮负数，且不能是隔膜者（若此时对方月亮与我12宫日月金之一合，改为抚慰者；若不满足抚慰者，且对方月亮对我除金木冲相外无其它刑冲且无火土天海冥任何相位或合盘指数高于300，改为 心灵归宿）
        // 月亮正数大于9且大于月亮负数且不能是隔膜者，或对方月亮与我日月之一合拱六分（若此时对方月亮与我12宫日月金之一合，或，对方月亮与我12宫日月金之一拱六分且对方日金水木之一与我12宫日月金之一合拱六分，改为抚慰者；若不满足抚慰者，且对方月亮对我除金木冲相外无其它刑冲且无火土天海冥任何相位或合盘指数高于300，改为 心灵归宿） 20190127
        //		百分比=（月亮正数-月亮负数）/2*10%
        //			允许高于100%（下同）
        if (($moonScore1['good'] >= 9
                && $moonScore1['good'] > $moonScore1['bad']
                && !in_array(3, $result['keywords'])) || checkPhase([1], [0, 1], [0, 60, 120], $data1['planets']))
        {
            $result['scores'][] = (($moonScore1['good'] - $moonScore1['bad']) * 10 / 2);

            $cond1 = false;
            // 我日月金中落12宫的星体数组
            $p013_in_house12 = [];
            foreach ([0, 1, 3] as $p1)
            {
                if ($data0['planets'][$p1]['in_house_id'] == 12)
                {
                    $p013_in_house12[] = $p1;
                }
            }
            if (count($p013_in_house12) >= 1)
            {
                if (checkPhase([1], $p013_in_house12, [0], $data1['planets'])
                    || (checkPhase([1], $p013_in_house12, [60, 120], $data1['planets'])
                        && checkPhase([0, 2, 3, 5], $p013_in_house12, [0, 60, 120])))
                {
                    $cond1 = true;
                }
            }
            // 抚慰者 2
            // 若此时对方月亮与我12宫日月金之一合，或，对方月亮与我12宫日月金之一拱六分且对方日金水木之一与我12宫日月金之一合拱六分，改为抚慰者
            if ($cond1 === true)
            {
                $result['keywords'][] = 2;
            }// 心灵归宿 37
            // 若不满足抚慰者，且对方月亮对我除金木冲相外无其它刑冲且无火土天海冥任何相位或合盘指数高于300，改为 心灵归宿
            elseif ($this->data['synastryScore'] >= 300
                || ($p1_phase_90180_num == 0 && $p1_phase_46789_num == 0))
            {
                $result['keywords'][] = 37;
            }// 关怀者 1
            else
            {
                $result['keywords'][] = 1;
            }
        }
        // 伤害者 5
        //	如果我对对方的月亮负数大于正数，且对方火土之一刑我月亮，对方是我的伤害者
        //		（我对他的月亮负数-我对他的月亮正数）/2*10%
        if (($moonScore2['bad'] > $moonScore2['good'])
            && ((isset($data1['planets'][4]['phase']['4-1'])
                    && $data1['planets'][4]['phase']['4-1']['phase_e'] == 90)
                || (isset($data1['planets'][6]['phase']['6-1'])
                    && $data1['planets'][6]['phase']['6-1']['phase_e'] == 90)))
        {
            $result['keywords'][] = 5;
            $result['scores'][] = (($moonScore2['bad'] - $moonScore2['good']) * 10 / 2);
        }
        // 倾心者 6
        //	月亮负数为零（或对方月亮与我除金木冲外无其它刑冲）正数不为零，且对方月亮与我金星成相
        //		月亮正数/2*10%
        if (($moonScore1['bad'] === 0 || $p1_phase_90180_num === 0) && $moonScore1['good'] > 0)
        {
            // 倾心者 6
            if (isset($data1['planets'][1]['phase']['1-3']))
            {
                $result['keywords'][] = 6;
                $result['scores'][] = ($moonScore1['good'] * 10 / 2);
            }
        }
        // 亲密无间者 7
        //  月亮正数不为零，且对方月亮与我月亮成合拱六分相，且，对方月亮必与我日金木之一成非刑相，且，对方月亮除与我日金木成冲相位外无其它任何刑冲
        //		月亮正数/2*10%
        if ($moonScore1['good'] > 0
            && isset($data1['planets'][1]['phase']['1-1']) && in_array($data1['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120])
            &&
            (
                (isset($data1['planets'][1]['phase']['1-0']) && $data1['planets'][1]['phase']['1-0']['phase_e'] != 90)
                || (isset($data1['planets'][1]['phase']['1-3']) && $data1['planets'][1]['phase']['1-3']['phase_e'] != 90)
                || (isset($data1['planets'][1]['phase']['1-5']) && $data1['planets'][1]['phase']['1-5']['phase_e'] != 90)
            )
            && $p1_phase_90180_num == 0
        )
        {
            $result['keywords'][] = 7;
            $result['scores'][] = ($moonScore1['good'] * 10 / 2);
        }
        // 追随者 8
        //  月亮负数为零（或对方月亮除与我金木冲外无其它刑冲），且对方月亮与我太阳成相
        //		我对对方的太阳正数/2*10%
        if (($moonScore1['bad'] === 0 || $p1_phase_90180_num == 0) && isset($data1['planets'][1]['phase']['1-0']))
        {
            $result['keywords'][] = 8;
            $result['scores'][] = ($sunScore2['good'] * 10 / 2);
        }

        //	爱慕者 9
        //		金星正数大于9，且我的日月之一或星群中点（力量10分以上）落在对方5或7宫或金月合下降
        //			（金星正数+我对他57宫激发数和/2）/3*10%
        $cond = false;
        if ($power1 >= 10)
        {
            foreach ($midPoint1 as $point)
            {
                if (in_array($this->isPointInHouse($data0, $point), [5, 7]))
                {
                    $cond = true;
                    break;
                }
            }
        }
        if ($venuScore1['good'] > 9
            &&
            (
                (isset($data3['planets'][1]['phase']['1-' . ASC]) && in_array($data3['planets'][1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                || (isset($data3['planets'][1]['phase']['1-' . MC]) && in_array($data3['planets'][1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                || (isset($data3['planets'][3]['phase']['3-' . ASC]) && in_array($data3['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                || (isset($data3['planets'][3]['phase']['3-' . MC]) && in_array($data3['planets'][3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                || in_array($data3['planets'][0]['in_house_id'], [5, 7])
                || in_array($data3['planets'][1]['in_house_id'], [5, 7])
                || $cond === true
            )
        )
        {
            $result['keywords'][] = 9;
            $result['scores'][] = ($venuScore1['good'] + ($houseScore2[5] + $houseScore2[7]) / 2) * 10 / 3;
        }
        //	殇情者 12
        //		金星正数大于9，且金星负数大于9，且负数大于正数
        //			金星负数/3*10%
        //		金星与对方日月金之二成相，且金星负数大于9
        //			金星负数/3*10%
        // 金星与对方的日月金成相数量
        $p3_phase_013_num = 0;
        if (!empty($data3['planets'][3]['phase']))
        {
            foreach ($data3['planets'][3]['phase'] as $phase)
            {
                if (in_array($phase['id'], [0, 1, 3]))
                {
                    $p3_phase_013_num++;
                }
            }
        }
        if (($venuScore1['bad'] > 9 && (($venuScore1['good'] > 9 && $venuScore1['bad'] > $venuScore1['good']) || $p3_phase_013_num >= 2)))
        {
            $result['keywords'][] = 12;
            $result['scores'][] = ($venuScore1['bad'] * 10 / 3);
        }
        //	仰慕者 10
        //		对方金星与我日月金之一成非刑相，且我日月金水之一落对方9宫（落9宫的星需与对方日月金木之一合拱六分）
        //			（金星正数+我对他9宫激发数/2）/3*10%
        //	服务者 11
        //		对方金星与我日月金之一成非刑相，且我日月之一落对方6宫
        //			（金星正数+我对他6宫激发数/2）/3*10%
        //	沟通者 19
        //		对方金星与我日月金之一成非刑相，且我日月金木之一落对方3宫（如金木落3宫需金木无刑相位且与对方日月之一成相）
        //      （如金木落3宫需金木无刑相位且与对方日月成相，如日月落3宫需日月与对方金水木成非刑相）20190118
        //			（金星正数+我对他3宫激发数/2）/3*10%
        //	社交者 20
        //      对方金星与我日月金之一成非刑相，且日月金木之一落我11宫（如金木落11宫需金木无刑相位且与我日月之一成相，如日月落11宫需与我日月金水木之一合拱六分）
        //	        （金星正数+11宫激发数/2）/3*10%
        if (
            (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
            || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
            || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
        )
        {
            // 仰慕者 10
            if (($data3['planets'][0]['in_house_id'] == 9
                    && (
                        (isset($data3['planets'][0]['phase']['0-0']) && in_array($data3['planets'][0]['phase']['0-0']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][0]['phase']['0-1']) && in_array($data3['planets'][0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][0]['phase']['0-3']) && in_array($data3['planets'][0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][0]['phase']['0-5']) && in_array($data3['planets'][0]['phase']['0-5']['phase_e'], [0, 60, 120]))
                    ))
                ||
                ($data3['planets'][1]['in_house_id'] == 9
                    && (
                        (isset($data3['planets'][1]['phase']['1-0']) && in_array($data3['planets'][1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][1]['phase']['1-1']) && in_array($data3['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][1]['phase']['1-3']) && in_array($data3['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][1]['phase']['1-5']) && in_array($data3['planets'][1]['phase']['1-5']['phase_e'], [0, 60, 120]))
                    ))
                ||
                ($data3['planets'][2]['in_house_id'] == 9
                    && (
                        (isset($data3['planets'][2]['phase']['2-0']) && in_array($data3['planets'][2]['phase']['2-0']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][2]['phase']['2-1']) && in_array($data3['planets'][2]['phase']['2-1']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][2]['phase']['2-3']) && in_array($data3['planets'][2]['phase']['2-3']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][2]['phase']['2-5']) && in_array($data3['planets'][2]['phase']['2-5']['phase_e'], [0, 60, 120]))
                    ))
                ||
                ($data3['planets'][3]['in_house_id'] == 9
                    && (
                        (isset($data3['planets'][3]['phase']['3-0']) && in_array($data3['planets'][3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][3]['phase']['3-1']) && in_array($data3['planets'][3]['phase']['3-1']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][3]['phase']['3-3']) && in_array($data3['planets'][3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                        || (isset($data3['planets'][3]['phase']['3-5']) && in_array($data3['planets'][3]['phase']['3-5']['phase_e'], [0, 60, 120]))
                    ))
            )
            {
                $result['keywords'][] = 10;
                $result['scores'][] = (($venuScore1['good'] + $houseScore2[9] / 2) * 10 / 3);
            }
            // 服务者 11
            if ($data3['planets'][0]['in_house_id'] == 6 || $data3['planets'][1]['in_house_id'] == 6)
            {
                $result['keywords'][] = 11;
                $result['scores'][] = (($venuScore1['good'] + $houseScore2[6] / 2) * 10 / 3);
            }
            // 沟通者 19
            if ($data3['planets'][0]['in_house_id'] == 3 || $data3['planets'][1]['in_house_id'] == 3
                || $data3['planets'][3]['in_house_id'] == 3 || $data3['planets'][5]['in_house_id'] == 3)
            {
                $cond = false;
                // 如金木落3宫需金木无刑相位且与对方日月成相
                if ($data3['planets'][0]['in_house_id'] != 3 && $data3['planets'][1]['in_house_id'] != 3)
                {
                    if ($data3['planets'][3]['in_house_id'] == 3)
                    {
                        $p3_has_phase_90 = false;
                        $p3_phase_01 = false;
                        if (!empty($data3['planets'][3]['phase']))
                        {
                            foreach ($data3['planets'][3]['phase'] as $phase)
                            {
                                if ($p3_has_phase_90 === false && $phase['phase_e'] == 90)
                                {
                                    $p3_has_phase_90 = true;
                                }
                                if ($p3_phase_01 === false && in_array($phase['id'], [0, 1]))
                                {
                                    $p3_phase_01 = true;
                                }
                            }
                        }
                        if ($p3_has_phase_90 === false && $p3_phase_01 === true)
                        {
                            $cond = true;
                        }
                    }

                    if ($cond === false && $data3['planets'][5]['in_house_id'] == 3)
                    {
                        $p5_has_phase_90 = false;
                        $p5_phase_01 = false;
                        if (!empty($data3['planets'][5]['phase']))
                        {
                            foreach ($data3['planets'][5]['phase'] as $phase)
                            {
                                if ($p5_has_phase_90 === false && $phase['phase_e'] == 90)
                                {
                                    $p5_has_phase_90 = true;
                                }
                                if ($p5_phase_01 === false && in_array($phase['id'], [0, 1]))
                                {
                                    $p5_phase_01 = true;
                                }
                            }
                        }
                        if ($p5_has_phase_90 === false || $p5_phase_01 === true)
                        {
                            $cond = true;
                        }
                    }
                }
                // 如日月落3宫需日月与对方金水木成非刑相
                if ($cond === false)
                {
                    if (($data3['planets'][0]['in_house_id'] == 3
                            && (
                                (isset($data3['planets'][0]['phase']['0-2'])
                                    && $data3['planets'][0]['phase']['0-2']['phase_e'] != 90)
                                || (isset($data3['planets'][0]['phase']['0-3'])
                                    && $data3['planets'][0]['phase']['0-3']['phase_e'] != 90)
                                || (isset($data3['planets'][0]['phase']['0-5'])
                                    && $data3['planets'][0]['phase']['0-5']['phase_e'] != 90)))
                        || ($data3['planets'][1]['in_house_id'] == 3
                            && ((isset($data3['planets'][1]['phase']['1-2'])
                                    && $data3['planets'][1]['phase']['1-2']['phase_e'] != 90)
                                || (isset($data3['planets'][1]['phase']['1-3'])
                                    && $data3['planets'][1]['phase']['1-3']['phase_e'] != 90)
                                || (isset($data3['planets'][1]['phase']['1-5'])
                                    && $data3['planets'][1]['phase']['1-5']['phase_e'] != 90))))
                    {
                        $cond = true;
                    }
                }
                if ($cond === true)
                {
                    $result['keywords'][] = 19;
                    $result['scores'][] = (($venuScore1['good'] + $houseScore2[3] / 2) * 10 / 3);
                }
            }
            // 社交者 20
            if ($data1['planets'][0]['in_house_id'] == 11 || $data1['planets'][1]['in_house_id'] == 11
                || $data1['planets'][3]['in_house_id'] == 11 || $data1['planets'][5]['in_house_id'] == 11)
            {
                $cond = false;
                // 如金木落11宫需金木无刑相位且与我日月之一成相
                if ($data1['planets'][0]['in_house_id'] != 11 && $data1['planets'][1]['in_house_id'] != 11)
                {
                    if ($data1['planets'][3]['in_house_id'] == 11)
                    {
                        $p3_has_phase_90 = false;
                        $p3_phase_01 = false;
                        if (!empty($data1['planets'][3]['phase']))
                        {
                            foreach ($data1['planets'][3]['phase'] as $phase)
                            {
                                if ($p3_has_phase_90 === false && $phase['phase_e'] == 90)
                                {
                                    $p3_has_phase_90 = true;
                                }
                                if ($p3_phase_01 === false && in_array($phase['id'], [0, 1]))
                                {
                                    $p3_phase_01 = true;
                                }
                            }
                        }
                        if ($p3_has_phase_90 === false && $p3_phase_01 === true)
                        {
                            $cond = true;
                        }
                    }

                    if ($cond === false && $data1['planets'][5]['in_house_id'] == 11)
                    {
                        $p5_has_phase_90 = false;
                        $p5_phase_01 = false;
                        if (!empty($data1['planets'][5]['phase']))
                        {
                            foreach ($data1['planets'][5]['phase'] as $phase)
                            {
                                if ($p5_has_phase_90 === false && $phase['phase_e'] == 90)
                                {
                                    $p5_has_phase_90 = true;
                                }
                                if ($p5_phase_01 === false && in_array($phase['id'], [0, 1]))
                                {
                                    $p5_phase_01 = true;
                                }
                            }
                        }
                        if ($p5_has_phase_90 === false || $p5_phase_01 === true)
                        {
                            $cond = true;
                        }
                    }
                }
                // 如日月落11宫需与我日月金水木之一合拱六分
                if ($cond === false)
                {
                    if ((
                            $data1['planets'][0]['in_house_id'] == 11
                            && (
                                (isset($data1['planets'][0]['phase']['0-0']) && in_array($data1['planets'][0]['phase']['0-0']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][0]['phase']['0-1']) && in_array($data1['planets'][0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][0]['phase']['0-2']) && in_array($data1['planets'][0]['phase']['0-2']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][0]['phase']['0-3']) && in_array($data1['planets'][0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][0]['phase']['0-5']) && in_array($data1['planets'][0]['phase']['0-5']['phase_e'], [0, 60, 120])))
                        )
                        ||
                        (
                            $data1['planets'][1]['in_house_id'] == 11
                            && (
                                (isset($data1['planets'][1]['phase']['1-0']) && in_array($data1['planets'][1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][1]['phase']['1-1']) && in_array($data1['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][1]['phase']['1-2']) && in_array($data1['planets'][1]['phase']['1-2']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][1]['phase']['1-3']) && in_array($data1['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                                || (isset($data1['planets'][1]['phase']['1-5']) && in_array($data1['planets'][1]['phase']['1-5']['phase_e'], [0, 60, 120])))
                        ))
                    {
                        $cond = true;
                    }
                }
                if ($cond === true)
                {
                    $result['keywords'][] = 20;
                    $result['scores'][] = (($venuScore1['good'] + $houseScore2[11] / 2) * 10 / 3);
                }
            }
        }
        //	甜蜜者 13
        //      对方是我的爱慕者，且金星负数为零（或除日月金木冲外无其它冲），同时，我也是对方的爱慕者，且金星、月亮负数均为零（或除日月金木冲外无其它冲）；合盘指数大于250
        //			（金星+月亮正数/2）/3*10%
        $cond = false;
        if ($power2 >= 10)
        {
            foreach ($midPoint2 as $point)
            {
                if (in_array($this->isPointInHouse($data1, $point), [5, 7]))
                {
                    $cond = true;
                    break;
                }
            }
        }
        if ($venuScore2['good'] > 9
            &&
            (
                (isset($data1['planets'][1]['phase']['1-' . ASC]) && in_array($data1['planets'][1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                || (isset($data1['planets'][1]['phase']['1-' . MC]) && in_array($data1['planets'][1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                || (isset($data1['planets'][3]['phase']['3-' . ASC]) && in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                || (isset($data1['planets'][3]['phase']['3-' . MC]) && in_array($data1['planets'][3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                || in_array($data1['planets'][0]['in_house_id'], [5, 7])
                || in_array($data1['planets'][1]['in_house_id'], [5, 7])
                || $cond === true
            )
        )
        {
            $cond1 = $cond2 = false;
            if (!empty($data3['planets'][3]['phase']))
            {
                foreach ($data3['planets'][3]['phase'] as $phase)
                {
                    if (!in_array($phase['id'], [0, 1, 3, 5]) && $phase['phase_e'] == 180)
                    {
                        $cond1 = true;
                    }
                }
            }
            if (!empty($data1['planets'][1]['phase']))
            {
                foreach ($data1['planets'][1]['phase'] as $phase)
                {
                    if (!in_array($phase['id'], [0, 1, 3, 5]) && $phase['phase_e'] == 180)
                    {
                        $cond2 = true;
                    }
                }
            }

            if (in_array(9, $result['keywords'])
                && ($venuScore1['bad'] === 0 || $cond1 === false)
                && ($moonScore2['bad'] === 0 || $cond2 === false) && $venuScore2['bad'] === 0
                && $this->data['synastryScore'] >= 250
            )
            {
                $result['keywords'][] = 13;
                $result['scores'][] = ($moonScore1['good'] / 2 + $venuScore1['good']) * 10 / 3;
            }
        }

        //	平等者 14
        //		对方月亮与我月亮合拱六分，对方太阳与我太阳合拱六分，且对方金星与我月亮成非刑相
        //			日月金正数之和/2*10%
        if (
            (isset($data1['planets'][1]['phase']['1-1']) && in_array($data1['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
            && (isset($data1['planets'][0]['phase']['0-0']) && in_array($data1['planets'][0]['phase']['0-0']['phase_e'], [0, 60, 120]))
            && (isset($data1['planets'][3]['phase']['3-1']) && in_array($data1['planets'][3]['phase']['3-1']['phase_e'], [0, 60, 120, 180]))
        )
        {
            $result['keywords'][] = 14;
            $result['scores'][] = ($sunScore1['good'] + $moonScore1['good'] + $venuScore1['good']) * 10 / 2;
        }
        //	快乐者 15
        //      对方金木均与我日月金之一成非刑相或合轴，或对方木星与我日月金之二成合拱六分，或对方木星与我日月金之一合拱六分并合我轴；我日月金与对方火土冥无刑冲合（若仅有金冥可无视）且对方火土冥不合我四轴
        //			我对ta日月金正数之和/2.5*10% 若日月金正数合为零，令其结果=20%
        // 对方木星与我日月金之二成合拱六分
        $p5_phase_013_060120_num = 0;
        if (!empty($data1['planets'][5]['phase']))
        {
            foreach ($data1['planets'][5]['phase'] as $phase)
            {
                if (in_array($phase['id'], [0, 1, 3]) && in_array($phase['phase_e'], [0, 60, 120]))
                {
                    $p5_phase_013_060120_num++;
                }
            }
        }
        $is_p3_phase_0_axis = false;
        if ((isset($data1['planets'][3]['phase']['3-' . ASC]) && in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
            || (isset($data1['planets'][3]['phase']['3-' . MC]) && in_array($data1['planets'][3]['phase']['3-' . MC]['phase_e'], [0, 180])))
        {
            $is_p3_phase_0_axis = true;
        }
        $is_p5_phase_0_axis = false;
        if ((isset($data1['planets'][5]['phase']['5-' . ASC]) && in_array($data1['planets'][5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
            || (isset($data1['planets'][5]['phase']['5-' . MC]) && in_array($data1['planets'][5]['phase']['5-' . MC]['phase_e'], [0, 180])))
        {
            $is_p5_phase_0_axis = true;
        }
        // 我日月金与对方火土冥无刑冲合（若仅有金冥可无视）
        $p013_phase_469_090180 = [];
        foreach ([0, 1, 3] as $p1)
        {
            if (!empty($data3['planets'][$p1]['phase']))
            {
                foreach ($data3['planets'][$p1]['phase'] as $phase)
                {
                    if (in_array($phase['id'], [4, 6, 9]) && in_array($phase['phase_e'], [0, 90, 180]))
                    {
                        $p013_phase_469_090180[] = $p1 . '-' . $phase['id'];
                    }
                }
            }
        }
        if (
            (
                (
                    (
                        (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                        || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                        || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                        || $is_p3_phase_0_axis === true
                    )
                    &&
                    (
                        (isset($data1['planets'][5]['phase']['5-0']) && $data1['planets'][5]['phase']['5-0']['phase_e'] != 90)
                        || (isset($data1['planets'][5]['phase']['5-1']) && $data1['planets'][5]['phase']['5-1']['phase_e'] != 90)
                        || (isset($data1['planets'][5]['phase']['5-3']) && $data1['planets'][5]['phase']['5-3']['phase_e'] != 90)
                        || $is_p5_phase_0_axis === true
                    )
                )
                ||
                ($p5_phase_013_060120_num >= 2 && $is_p5_phase_0_axis === true)

            )
            &&
            (
                count($p013_phase_469_090180) === 0
                || (count($p013_phase_469_090180) === 1 && $p013_phase_469_090180[0] == '3-9')
            )
            && (!isset($data1['planets'][4]['phase']['4-' . ASC]) || !in_array($data1['planets'][4]['phase']['4-' . ASC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][4]['phase']['4-' . MC]) || !in_array($data1['planets'][4]['phase']['4-' . MC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][6]['phase']['6-' . ASC]) || !in_array($data1['planets'][6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][6]['phase']['6-' . MC]) || !in_array($data1['planets'][6]['phase']['6-' . MC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][9]['phase']['9-' . ASC]) || !in_array($data1['planets'][9]['phase']['9-' . ASC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][9]['phase']['9-' . MC]) || !in_array($data1['planets'][9]['phase']['9-' . MC]['phase_e'], [0, 180]))
        )
        {
            $result['keywords'][] = 15;
            // 我对ta日月金正数之和/2.5*10%
            $sum = ($sunScore2['good'] + $moonScore2['good'] + $venuScore2['good']) * 10 / 2.5;
            if ($sum === 0)
            {
                $sum = 20;
            } else
            {
                $sum *= 2;
            }
            $result['scores'][] = $sum;
        }

        // 太阳篇
        //	认同者 16
        //		对方太阳或金星与我的太阳合拱六分，且对方金月与我日月金不构成非刑相位且不合我轴
        //      对方日月金之一与我的太阳合拱六分，另一与我的太阳成非刑相位 20190119
        //			我对他的太阳正数/3*10%
        $cond = false;
        $pls = [0, 1, 3];
        foreach ($pls as $p1)
        {
            foreach ($pls as $p2)
            {
                if ($cond == false && $p1 != $p2)
                {
                    if ((isset($data1['planets'][$p1]['phase'][$p1 . '-0']) && in_array($data1['planets'][$p1]['phase'][$p1 . '-0']['phase_e'], [0, 60, 120]))
                        && (isset($data1['planets'][$p2]['phase'][$p2 . '-0']) && $data1['planets'][$p2]['phase'][$p2 . '-0']['phase_e'] != 90))
                    {
                        $cond = true;
                        break;
                    }
                }
            }
        }
        if ($cond === true)
        {
            $result['keywords'][] = 16;
            $result['scores'][] = $sunScore1['good'] * 10 / 3;
        }

        // 缘分篇
        //	羁绊者 17命运线
        //      粘合数不为零，且【对方日月金之一与我日月之一成非刑相或合我轴（每多一组最终计分+15%）】
        //			粘合数/5*10% 粘合数/10*10%,超过300%令其=300
        if ($glueScore1 > 0)
        {
            $p013_phase_01_no90_num = 0;
            foreach ([0, 1, 3] as $p1)
            {
                if (!empty($data1['planets'][$p1]['phase']))
                {
                    foreach ($data1['planets'][$p1]['phase'] as $phase)
                    {
                        if ((in_array($phase['id'], [0, 1]) && $phase['phase_e'] != 90)
                            || (in_array($phase['id'], [ASC, MC]) && in_array($phase['phase_e'], [0, 180])))
                        {
                            $p013_phase_01_no90_num++;
                        }
                    }
                }
            }
            if ($p013_phase_01_no90_num > 0)
            {
                $result['keywords'][] = 17;
//                $result['scores'][] = $glueScore1 * 10 / 5 + 15 * ($p013_phase_01_no90_num - 1);
                // 粘合数/10*10%,超过300%令其=300
                $score = $glueScore1 * 10 / 10 + 15 * ($p013_phase_01_no90_num - 1);
                if ($score > 300) $score = 300;
                $result['scores'][] = $score;
            }
        }
        //宿命者
        // 前世镜18
        // 三生石38
        //      宿命数高于5，且至少与我有日月、月月、月金一组合拱六分相或日月金与升降轴的合相（宿命数高于9【且合盘指数高于250】或合盘指数高于350时为“三生石”，否则是“前世镜”）
        //			（宿命数-4）*10%
        if ($destinyScore1 >= 5
            &&
            (
                (
                    (isset($data1['planets'][0]['phase']['0-1']) && in_array($data1['planets'][0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                    || (isset($data1['planets'][1]['phase']['1-1']) && in_array($data1['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                    || (isset($data1['planets'][1]['phase']['1-3']) && in_array($data1['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                )
                ||
                (
                    (isset($data1['planets'][0]['phase']['0-' . ASC]) && in_array($data1['planets'][0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                    || (isset($data1['planets'][1]['phase']['1-' . ASC]) && in_array($data1['planets'][1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                    || (isset($data1['planets'][3]['phase']['3-' . ASC]) && in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                )
            )
        )
        {
            if (($destinyScore1 >= 9 && $this->data['synastryScore'] >= 250) || $this->data['synastryScore'] >= 350)
            {
                $result['keywords'][] = 38;
            } else
            {
                $result['keywords'][] = 18;
            }

            $result['scores'][] = ($destinyScore1 - 4) * 10;
        }

        //火星篇
        //	激情者 21：能对我产生激情，有强烈性吸引的人
        //      火星正数减去负数高于7，且两人相差不超过20岁
        //		火星正数高于7
        //			（火星正数-6）*10%
        if ($marsScore1['good'] - $marsScore1['bad'] >= 7 && $yearDiff <= 20)
        {
            $result['keywords'][] = 21;
            $result['scores'][] = ($marsScore1['good'] - 6) * 10;
        }

        // 其它篇
        //	白月光 23
        //		ta的日月之一落我9宫，且与我日金之一合拱六分；两个合盘指数高于250；我对ta金星正数高于7；我月亮与ta月亮刑相位且不与日金水合拱六分，或我月亮落对方12宫且不与对方日月金水合拱六分（分号为并列条件）
        //			（合盘指数-240）*1%
        if (
            (
                (
                    $data1['planets'][0]['in_house_id'] == 9
                    &&
                    (
                        (isset($data1['planets'][0]['phase']['0-0']) && in_array($data1['planets'][0]['phase']['0-0']['phase_e'], [0, 60, 120]))
                        || (isset($data1['planets'][0]['phase']['0-3']) && in_array($data1['planets'][0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                    )
                )
                ||
                (
                    $data1['planets'][1]['in_house_id'] == 9
                    &&
                    (
                        (isset($data1['planets'][1]['phase']['1-0']) && in_array($data1['planets'][1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                        || (isset($data1['planets'][1]['phase']['1-3']) && in_array($data1['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                    )
                )
            )
            && $this->data['synastryScore'] >= 250
            && $venuScore2['good'] > 7
            &&
            (
                (
                    (isset($data0['planets'][1]['phase']['1-1']) && $data0['planets'][1]['phase']['1-1']['phase_e'] == 90)
                    ||
                    (
                        $data3['planets'][1]['in_house_id'] == 12
                        && (!isset($data0['planets'][1]['phase']['1-1']) || !in_array($data0['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                    )
                )
                && (!isset($data0['planets'][1]['phase']['1-0']) || !in_array($data0['planets'][1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                && (!isset($data0['planets'][1]['phase']['1-2']) || !in_array($data0['planets'][1]['phase']['1-2']['phase_e'], [0, 60, 120]))
                && (!isset($data0['planets'][1]['phase']['1-3']) || !in_array($data0['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
            )
        )
        {
            $result['keywords'][] = 23;
            $result['scores'][] = ($this->data['synastryScore'] - 240) * 1;
        }
        //	心灵影子 26
        //		对方太阳、月亮、上升星座与我的太阳、月亮、上升星座相同（可打乱次序），且对方日月金水不与我火星刑冲
        //			合盘指数/200*40%
        // 日月升数组
        $sunMoonAsc1 = [$data1['planets'][0]['in_sign_id'], $data1['planets'][1]['in_sign_id'], $data1['planets'][ASC]['in_sign_id']];
        $sunMoonAsc2 = [$data3['planets'][0]['in_sign_id'], $data3['planets'][1]['in_sign_id'], $data3['planets'][ASC]['in_sign_id']];
        // 日月升数组排序
        sort($sunMoonAsc1);
        sort($sunMoonAsc2);
        if ($sunMoonAsc1 == $sunMoonAsc2
            &&
            (
                (!isset($data1['planets'][0]['phase']['0-4']) || !in_array($data1['planets'][0]['phase']['0-4']['phase_e'], [90, 180]))
                && (!isset($data1['planets'][1]['phase']['1-4']) || !in_array($data1['planets'][1]['phase']['1-4']['phase_e'], [90, 180]))
                && (!isset($data1['planets'][2]['phase']['2-4']) || !in_array($data1['planets'][2]['phase']['2-4']['phase_e'], [90, 180]))
                && (!isset($data1['planets'][3]['phase']['3-4']) || !in_array($data1['planets'][3]['phase']['3-4']['phase_e'], [90, 180]))
            )
        )
        {
            $result['keywords'][] = 26;
            $result['scores'][] = $this->data['synastryScore'] / 5;
        }
        //	镜面桃花 25
        //		对方日月星座都是我日座或月座的对宫星座（且不与我日月星座任一同元素），且冲断数大于10，对方金星与我日月金火之一成非刑相或合我升降点
        //			冲断数/10*30%
        $sunSign1 = $data3['planets'][0]['in_sign_id'];
        $moonSign1 = $data3['planets'][1]['in_sign_id'];
        $sunSign2 = $data1['planets'][0]['in_sign_id'];
        $moonSign2 = $data1['planets'][1]['in_sign_id'];
        if ($thrustScore1 > 10
            &&
            (
                (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-4']) && $data1['planets'][3]['phase']['3-4']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-' . ASC]) && in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
            )
        )
        {
            if ($sunSign2 != $sunSign1 && $sunSign2 != $moonSign1 && $moonSign2 != $sunSign1 && $moonSign2 != $moonSign1)
            {
                if (
                    (($sunSign2 + 6) == $sunSign1 || ($sunSign2 - 6) == $sunSign1 || ($sunSign2 + 6) == $moonSign1 || ($sunSign2 - 6) == $moonSign1)
                    && (($moonSign2 + 6) == $sunSign1 || ($moonSign2 - 6) == $sunSign1 || ($moonSign2 + 6) == $moonSign1 || ($moonSign2 - 6) == $moonSign1)
                )
                {
                    $result['keywords'][] = 25;
                    $result['scores'][] = $thrustScore1 * 30 / 10;
                }
            }
        }
        //	彼岸花 24
        //      两人比较盘日月金水与日月金水火土之间的冲相位不少于4组，且冲断数不为零，且对方金星与我日月金水火之一成非刑相或合我升降点【若一方日月星座之一与对方日月星座之一同元素或成六分相位则不成立】
        //			合盘冲突值/20*50%
        $cond = false;
        $signElement1 = $sunSign1 % 4;
        $signElement2 = $moonSign1 % 4;
        $signElement3 = $sunSign2 % 4;
        $signElement4 = $moonSign2 % 4;
        if ($signElement1 === $signElement3 || $signElement1 === $signElement4 || $signElement2 === $signElement3 || $signElement2 === $signElement4)
        {
            $cond = true;
        }
        if ($cond === false && (checkPhase([0, 1], [0, 1], [60], $data1) || checkPhase([0, 1], [0, 1], [60], $data3)))
        {
            $cond = true;
        }
        if ($cond === false)
        {
            $p0123_phase_012346_180_num = 0;
            foreach ([0, 1, 2, 3] as $p1)
            {
                foreach ([0, 1, 2, 3, 4, 6] as $p2)
                {
                    if (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]) && $data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'] == 180)
                    {
                        $p0123_phase_012346_180_num++;
                    }
                    if (isset($data3['planets'][$p1]['phase'][$p1 . '-' . $p2]) && $data3['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'] == 180)
                    {
                        $p0123_phase_012346_180_num++;
                    }
                }
            }
            if ($p0123_phase_012346_180_num >= 4
                && $thrustScore1 > 0
                &&
                (
                    (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-2']) && $data1['planets'][3]['phase']['3-2']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-4']) && $data1['planets'][3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-' . ASC]) && in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                )
            )
            {
                $result['keywords'][] = 24;
                $result['scores'][] = $this->option['harmoniousConflict'][1] * 50 / 20;
            }
        }

        //	鹊桥仙子 27
        //		1、对方性别女；我本命金星水瓶或金星与天王成相或金星9宫或月亮9宫，对方金星水瓶或金星与天王成相或金星9宫或太阳9宫；对方金星与我日月金成非刑相，或我金星与对方日月金成非刑相
        //			合盘指数/200*50%
        //		2、对方性别女；我天王合对方轴点或与对方月亮成相位，且对方天王也对我如此；我与对方天王度数差高于5度；对方金星与我日月金成非刑相，或我金星与对方日月金成非刑相
        //			合盘指数/200*50%
        if ($i === 0 && $recode2['type'] != 1)
        {
            $cond = false;
            if ((
                    $nata1['planets'][3]['in_sign_id'] == 11
                    || isset($nata1['planets'][3]['phase']['3-7'])
                    || $nata1['planets'][1]['in_house_id'] == 9
                    || $nata1['planets'][3]['in_house_id'] == 9
                )
                &&
                (
                    $nata2['planets'][3]['in_sign_id'] == 11
                    || isset($nata2['planets'][3]['phase']['3-7'])
                    || $nata2['planets'][0]['in_house_id'] == 9
                    || $nata2['planets'][3]['in_house_id'] == 9
                )
            )
            {
                if (
                    (
                        (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                        || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                        || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                    )
                    ||
                    (
                        (isset($data3['planets'][3]['phase']['3-0']) && $data3['planets'][3]['phase']['3-0']['phase_e'] != 90)
                        || (isset($data3['planets'][3]['phase']['3-1']) && $data3['planets'][3]['phase']['3-1']['phase_e'] != 90)
                        || (isset($data3['planets'][3]['phase']['3-3']) && $data3['planets'][3]['phase']['3-3']['phase_e'] != 90)
                    )
                )
                {
                    $cond = true;
                }
            }
            if (
                $cond === false
                &&
                (
                    (isset($data3['planets'][7]['phase']['7-' . ASC]) && in_array($data3['planets'][7]['phase']['7-' . ASC]['phase_e'], [0, 180]))
                    || (isset($data3['planets'][7]['phase']['7-' . MC]) && in_array($data3['planets'][7]['phase']['7-' . MC]['phase_e'], [0, 180]))
                    || isset($data3['planets'][7]['phase']['7-1'])
                )
                &&
                (
                    (isset($data1['planets'][7]['phase']['7-' . ASC]) && in_array($data1['planets'][7]['phase']['7-' . ASC]['phase_e'], [0, 180]))
                    || (isset($data1['planets'][7]['phase']['7-' . MC]) && in_array($data1['planets'][7]['phase']['7-' . MC]['phase_e'], [0, 180]))
                    || isset($data1['planets'][7]['phase']['7-1'])
                )
                && (!isset($data1['planets'][7]['phase']['7-7']) || $data1['planets'][7]['phase']['7-7']['phase_e'] != 0)
                &&
                // 对方金星与我日月金成非刑相，或我金星与对方日月金成非刑相
                (
                    (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                    || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                    || (isset($data3['planets'][3]['phase']['3-0']) && $data3['planets'][3]['phase']['3-0']['phase_e'] != 90)
                    || (isset($data3['planets'][3]['phase']['3-1']) && $data3['planets'][3]['phase']['3-1']['phase_e'] != 90)
                )

            )
            {
                $cond = true;
            }
            if ($cond === true)
            {
                $result['keywords'][] = 27;
                $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
            }
        }
        //	合欢铃 29
        //		双方金星都不与对方日月金成非刑相；对方火星与我日月之一合拱六分，且与我金火之一成非刑相【两人相差不超过20岁】
        //			合盘激情指数*1.5%
        if (
            $yearDiff <= 20
            &&
            (
                (!isset($data1['planets'][3]['phase']['3-0']) || in_array($data1['planets'][3]['phase']['3-0']['phase_e'], [90]))
                && (!isset($data1['planets'][3]['phase']['3-1']) || in_array($data1['planets'][3]['phase']['3-1']['phase_e'], [90]))
                && (!isset($data1['planets'][3]['phase']['3-3']) || in_array($data1['planets'][3]['phase']['3-3']['phase_e'], [90]))
                && (!isset($data3['planets'][3]['phase']['3-0']) || in_array($data3['planets'][3]['phase']['3-0']['phase_e'], [90]))
                && (!isset($data3['planets'][3]['phase']['3-1']) || in_array($data3['planets'][3]['phase']['3-1']['phase_e'], [90]))
            )
            &&
            (
                (isset($data1['planets'][4]['phase']['4-0']) && in_array($data1['planets'][4]['phase']['4-0']['phase_e'], [0, 60, 120]))
                || (isset($data1['planets'][4]['phase']['4-1']) && in_array($data1['planets'][4]['phase']['4-1']['phase_e'], [0, 60, 120]))
            )
            &&
            (
                (isset($data1['planets'][4]['phase']['4-3']) && !in_array($data1['planets'][4]['phase']['4-3']['phase_e'], [90]))
                || (isset($data1['planets'][4]['phase']['4-4']) && !in_array($data1['planets'][4]['phase']['4-4']['phase_e'], [90]))
            )
        )
        {
            $result['keywords'][] = 29;
            $result['scores'][] = $this->option['synastryScore']['passion'] * 1.5;
        }
        //	情花 28
        //		若我本命金星与火土海冥之二同时刑冲，对方日月金之一与【我火土海冥中刑冲金星者冲合且刑冲我金星】，且，对方日月金【上升】之一落我5/7或我金星与对方日月金之一成非刑相
        //			若粘合数不为零，粘合数/4*10%；若粘合数为零，合盘缘分数/50*50%
        $na_p3_phase_4689_90180 = [];
        if (!empty($nata1['planets'][3]['phase']))
        {
            foreach ($nata1['planets'][3]['phase'] as $phase)
            {
                if (in_array($phase['id'], [4, 6, 8, 9]) && in_array($phase['phase_e'], [90, 180]))
                {
                    $na_p3_phase_4689_90180[] = $phase['id'];
                }
            }
        }
        if (count($na_p3_phase_4689_90180) >= 2)
        {
            // 加入中天
            $na_p3_phase_4689_90180[] = MC;

            $cond = false;

            foreach ($na_p3_phase_4689_90180 as $pid)
            {
                if (
                    $cond === false
                    &&
                    (
                        (isset($data1['planets'][0]['phase']['0-' . $pid]) && in_array($data1['planets'][0]['phase']['0-' . $pid]['phase_e'], [0, 180])
                            && isset($data1['planets'][0]['phase']['0-3']) && in_array($data1['planets'][0]['phase']['0-3']['phase_e'], [90, 180]))
                        ||
                        (isset($data1['planets'][1]['phase']['1-' . $pid]) && in_array($data1['planets'][1]['phase']['1-' . $pid]['phase_e'], [0, 180])
                            && isset($data1['planets'][1]['phase']['1-3']) && in_array($data1['planets'][1]['phase']['1-3']['phase_e'], [90, 180]))
                        ||
                        (isset($data1['planets'][3]['phase']['3-' . $pid]) && in_array($data1['planets'][3]['phase']['3-' . $pid]['phase_e'], [0, 180])
                            && isset($data1['planets'][3]['phase']['3-3']) && in_array($data1['planets'][3]['phase']['3-3']['phase_e'], [90, 180]))
                    )
                )
                {
                    $cond = true;
                }
            }
            // 且，对方日月金【上升】之一落我5/7或我金星与对方日月金之一成非刑相
            if ($cond == true
                &&
                (
                    in_array($data1['planets'][0]['in_house_id'], [5, 7])
                    || in_array($data1['planets'][1]['in_house_id'], [5, 7])
                    || in_array($data1['planets'][3]['in_house_id'], [5, 7])
                    || in_array($data1['planets'][ASC]['in_house_id'], [5, 7])
                    || (isset($data3['planets'][3]['phase']['3-0']) && !in_array($data3['planets'][3]['phase']['3-0']['phase_e'], [90]))
                    || (isset($data3['planets'][3]['phase']['3-1']) && !in_array($data3['planets'][3]['phase']['3-1']['phase_e'], [90]))
                    || (isset($data3['planets'][3]['phase']['3-3']) && !in_array($data3['planets'][3]['phase']['3-3']['phase_e'], [90]))
                )
            )
            {
                $result['keywords'][] = 28;
                if ($glueScore1 > 0)
                {
                    $result['scores'][] = $glueScore1 * 2.5;
                } else
                {
                    $result['scores'][] = $this->option['synastryScore']['probTobeLover'];
                }
            }
        }
        //	生死恋 30
        //		双方金星均与对方的日月金上升之一成非刑相；双方金星均与对方的冥王成相位，且双方冥王不成合相；比较盘必须有日月、月月、月金的非刑相之一
        //          （金星正数+金星负数/2）/15*50%;若金星正数负数都为零，结果改为 合盘指数/200*50%
        if (
            (
                (isset($data1['planets'][3]['phase']['3-0']) && $data1['planets'][3]['phase']['3-0']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-1']) && $data1['planets'][3]['phase']['3-1']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-3']) && $data1['planets'][3]['phase']['3-3']['phase_e'] != 90)
                || (isset($data1['planets'][3]['phase']['3-' . ASC]) && $data1['planets'][3]['phase']['3-' . ASC]['phase_e'] != 90)
            )
            &&
            (
                (isset($data3['planets'][3]['phase']['3-0']) && $data3['planets'][3]['phase']['3-0']['phase_e'] != 90)
                || (isset($data3['planets'][3]['phase']['3-1']) && $data3['planets'][3]['phase']['3-1']['phase_e'] != 90)
                || (isset($data3['planets'][3]['phase']['3-3']) && $data3['planets'][3]['phase']['3-3']['phase_e'] != 90)
                || (isset($data3['planets'][3]['phase']['3-' . ASC]) && $data3['planets'][3]['phase']['3-' . ASC]['phase_e'] != 90)
            )
            &&
            (isset($data1['planets'][3]['phase']['3-9']) && isset($data3['planets'][3]['phase']['3-9']) && !isset($data1['planets'][9]['phase']['9-9']))
            &&
            (
                (isset($data1['planets'][0]['phase']['0-1']) && $data1['planets'][0]['phase']['0-1']['phase_e'] != 90)
                || (isset($data1['planets'][1]['phase']['1-1']) && $data1['planets'][1]['phase']['1-1']['phase_e'] != 90)
                || (isset($data1['planets'][1]['phase']['1-3']) && $data1['planets'][1]['phase']['1-3']['phase_e'] != 90)
                || (isset($data3['planets'][0]['phase']['0-1']) && $data3['planets'][0]['phase']['0-1']['phase_e'] != 90)
                || (isset($data3['planets'][1]['phase']['1-3']) && $data3['planets'][1]['phase']['1-3']['phase_e'] != 90)
            )
        )
        {
            $result['keywords'][] = 30;
            if ($venuScore1['good'] === 0 && $venuScore1['bad'] === 0)
            {
                $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
            } else
            {
                $result['scores'][] = ($venuScore1['good'] + $venuScore1['bad'] / 2) * 50 / 15;
            }
        }

        // 补充
        //	快乐拼图 31
        //		1、你本命有某个由日月金水火木之二够成的三分相，而对方的日月金木之一同时与该三分相两端形成三分相
        //		2、你本命有某个由日月金水木之二够成的六分相，而对方的日月金木之一同时与该六分相两端形成三分或六分
        //			合盘指数/200*50%
        $pls = [0, 1, 2, 3, 4, 5];
        $cond = false;
        foreach ($pls as $p1)
        {
            // 自己本命星相位
            if (!empty($nata1['planets'][$p1]['phase']))
            {
                foreach ($nata1['planets'][$p1]['phase'] as $phase)
                {
                    if ($cond === false && in_array($phase['id'], $pls) && $phase['phase_e'] == 120)
                    {
                        foreach ([0, 1, 3, 5] as $p2)
                        {
                            if ($cond === false && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $p1]) && $data1['planets'][$p2]['phase'][$p2 . '-' . $p1]['phase_e'] == 120
                                && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']]) && $data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']]['phase_e'] == 120)
                            {
                                $cond = true;
                                break;
                            }
                        }
                    }
                    if ($cond === false && in_array($p1, [0, 1, 2, 3, 5]) && in_array($phase['id'], [0, 1, 2, 3, 5]) && $phase['phase_e'] == 60)
                    {
                        foreach ([0, 1, 3, 5] as $p2)
                        {
                            if ($cond === false
                                && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $p1])
                                && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $p1]['phase_e'], [60, 120])
                                && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']])
                                && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']]['phase_e'], [60, 120]))
                            {
                                $cond = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
        if ($cond === true)
        {
            $result['keywords'][] = 31;
            $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
        }
        //	痛苦拼图 32
        //		1、你本命有某个由日月金水与日月金水火土构成的四分相，而对方的火星与该相位两端同时刑冲
        //		2、你本命有某个由日月金水与火土构成的四分相，而对方的日月金火与该相位两端同时刑冲
        //		3、你本命有某个由日月金水与日月金水火土构成的对分相，而对方的火星与该相位两端同时相刑
        //		4、你本命有某个由日月金水与火土构成的对分相，而对方的日月金火星与该相位两端同时相刑
        //			合盘冲突指数/30*50%
        $pls1 = [0, 1, 2, 3];
        $pls2 = [0, 1, 2, 3, 4, 6];
        $cond = false;
        foreach ($pls1 as $p1)
        {
            // 自己本命星相位
            if (!empty($nata1['planets'][$p1]['phase']))
            {
                foreach ($nata1['planets'][$p1]['phase'] as $phase)
                {
                    if ($cond === false && in_array($phase['id'], $pls2))
                    {
                        if ($cond === false && $phase['phase_e'] == 90)
                        {
                            if (isset($data1['planets'][4]['phase']['4-' . $p1])
                                && in_array($data1['planets'][4]['phase']['4-' . $p1]['phase_e'], [90, 180])
                                && isset($data1['planets'][4]['phase']['-' . $phase['id']])
                                && in_array($data1['planets'][4]['phase']['4-' . $phase['id']]['phase_e'], [90, 180]))
                            {
                                $cond = true;
                                break;
                            }
                        } elseif ($cond === false && $phase['phase_e'] == 180)
                        {
                            if (isset($data1['planets'][4]['phase']['4-' . $p1])
                                && in_array($data1['planets'][4]['phase']['4-' . $p1]['phase_e'], [90])
                                && isset($data1['planets'][4]['phase']['-' . $phase['id']])
                                && in_array($data1['planets'][4]['phase']['4-' . $phase['id']]['phase_e'], [90]))
                            {
                                $cond = true;
                                break;
                            }
                        }

                    }
                    if ($cond === false && in_array($phase['id'], [4, 6]))
                    {
                        foreach ([0, 1, 3, 4] as $p2)
                        {
                            if ($cond === false && $phase['phase_e'] == 60)
                            {
                                if (isset($data1['planets'][$p2]['phase'][$p2 . '-' . $p1])
                                    && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $p1]['phase_e'], [90, 180])
                                    && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']])
                                    && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']]['phase_e'], [90, 180]))
                                {
                                    $cond = true;
                                    break;
                                }
                            } elseif ($cond === false && $phase['phase_e'] == 180)
                            {
                                if (isset($data1['planets'][$p2]['phase'][$p2 . '-' . $p1])
                                    && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $p1]['phase_e'], [90])
                                    && isset($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']])
                                    && in_array($data1['planets'][$p2]['phase'][$p2 . '-' . $phase['id']]['phase_e'], [90]))
                                {
                                    $cond = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($cond === true)
        {
            $result['keywords'][] = 32;
            $result['scores'][] = $this->option['harmoniousConflict'][1] * 50 / 30;
        }
        //	守护天使 33
        //		对方日月金水之一合你天底或落4宫，且与你日月金木之一合拱六分（每多一组，得分+30%）；对方木星合你轴点或与你日月成非刑相或合你北交（每多一组得分+20%）；对方月亮与你日金月之一合拱六分；对方日月金水之一落你5宫且与你日月金木之一合拱六分（每多一组，得分+20%）；你的月亮与ta没有刑相，且没有火土冥海的冲相
        //			合盘指数/300*50%+20%
        if (checkPhase([1], [0, 1, 3], [0, 60, 120], $data1['planets'])
            && checkSignHouse([0, 1, 2, 3], [5], $data1['planets']))
        {
            // 日月水金
            $pls1 = [0, 1, 2, 3];
            // 日月金木
            $pls2 = [0, 1, 3, 5];
            $is_p1_phase_4689_180 = false;
            if (!empty($data3['planets'][1]['phase']))
            {
                foreach ($data3['planets'][1]['phase'] as $phase)
                {
                    if ($phase['phase_e'] == 90 || (in_array($phase['id'], [4, 6, 8, 9]) && $phase['phase_e'] == 180))
                    {
                        $is_p1_phase_4689_180 = true;
                    }
                }
            }
            $num1 = $num2 = $num3 = 0;
            if ($is_p1_phase_4689_180 === false)
            {
                foreach ($pls1 as $p1)
                {
                    if (($data1['planets'][$p1]['in_house_id'] == 4
                        || (isset($data1['planets'][$p1]['phase'][$p1 . '-' . MC])
                            && $data1['planets'][$p1]['phase'][$p1 . '-' . MC]['phase_e'] == 180))
                    )
                    {
                        foreach ($pls2 as $p2)
                        {
                            if (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                                && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                            {
                                $num1++;
                            }
                        }
                    } elseif ($data1['planets'][$p1]['in_house_id'] == 5)
                    {
                        foreach ($pls2 as $p2)
                        {
                            if (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                                && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                            {
                                $num3++;
                            }
                        }
                    }
                }
            }
            if ((isset($data1['planets'][5]['phase']['5-' . ASC]) && in_array($data1['planets'][5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
                || (isset($data1['planets'][5]['phase']['5-' . MC]) && in_array($data1['planets'][5]['phase']['5-' . MC]['phase_e'], [0, 180])))
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-0']) && $data1['planets'][5]['phase']['5-0']['phase_e'] != 90)
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-1']) && $data1['planets'][5]['phase']['5-1']['phase_e'] != 90)
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-12']) && $data1['planets'][5]['phase']['5-12']['phase_e'] == 0)
            {
                $num2++;
            }

            if ($is_p1_phase_4689_180 === true && $num1 > 0 && $num2 > 0 && $num3 > 0)
            {
                $result['keywords'][] = 33;
                $result['scores'][] = $this->data['synastryScore'] * 50 / 300 + 20 + ($num1 - 1) * 30 + ($num2 - 1) * 20 + ($num3 - 1) * 20;
            }
        }
        //	引路天使 34
        //		对方日月金水之一合你中天或落10宫，且与你日月金木之一合拱六分（每多一组，得分+30%）；对方木星合你轴点或与你日月成非刑相或合你北交（每多一组得分+20%）；对方太阳与你金月之一合拱六分；对方日月金水之一落你11宫且与你日月金木之一合拱六分（每多一组，得分+20%）；你们有日金、日月、金月的合拱六分相之一
        //			合盘指数/300*50%+20%
        if (checkPhase([0], [1, 3], [0, 60, 120], $data1['planets'])
            && ((isset($data1['planets'][0]['phase']['0-1']) && in_array($data1['planets'][0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                || (isset($data1['planets'][0]['phase']['0-3']) && in_array($data1['planets'][0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                || (isset($data1['planets'][3]['phase']['3-1']) && in_array($data1['planets'][3]['phase']['3-1']['phase_e'], [0, 60, 120]))))
        {
            // 日月水金
            $pls1 = [0, 1, 2, 3];
            // 日月金木
            $pls2 = [0, 1, 3, 5];
            $num1 = $num2 = $num3 = 0;
            foreach ($pls1 as $p1)
            {
                if (($data1['planets'][$p1]['in_house_id'] == 10
                    || (isset($data1['planets'][$p1]['phase'][$p1 . '-' . MC])
                        && $data1['planets'][$p1]['phase'][$p1 . '-' . MC]['phase_e'] == 0))
                )
                {
                    foreach ($pls2 as $p2)
                    {
                        if (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                            && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                        {
                            $num1++;
                        }
                    }
                } elseif ($data1['planets'][$p1]['in_house_id'] == 11)
                {
                    foreach ($pls2 as $p2)
                    {
                        if (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                            && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                        {
                            $num3++;
                        }
                    }
                }
            }

            if ((isset($data1['planets'][5]['phase']['5-' . ASC]) && in_array($data1['planets'][5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
                || (isset($data1['planets'][5]['phase']['5-' . MC]) && in_array($data1['planets'][5]['phase']['5-' . MC]['phase_e'], [0, 180])))
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-0']) && $data1['planets'][5]['phase']['5-0']['phase_e'] != 90)
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-1']) && $data1['planets'][5]['phase']['5-1']['phase_e'] != 90)
            {
                $num2++;
            }
            if (isset($data1['planets'][5]['phase']['5-12']) && $data1['planets'][5]['phase']['5-12']['phase_e'] == 0)
            {
                $num2++;
            }
            if ($num1 > 0 && $num2 > 0 && $num3 > 0)
            {
                $result['keywords'][] = 34;
                $result['scores'][] = $this->data['synastryScore'] * 50 / 300 + 20 + ($num1 - 1) * 30 + ($num2 - 1) * 20 + ($num3 - 1) * 20;
            }
        }
        //	陷阱 35
        //		1、你本命金星同时被火土冥海之二刑冲，或位于T三角顶点，或落在8/12宫被火土冥海之一合另一刑冲，此时对方火星与我刑冲金星的火土冥海之一冲合并刑冲我金星，且对方海王与我月金成相，且对方没有与我的月月、月金、日月、日金的合拱六分，且对方金木不合我轴
        //		2、你本命月亮同时被火土冥海之二刑冲，或位于T三角顶点，或落在8/12宫被火土冥海之一合另一刑冲，此时对方火星与我刑冲金星的火土冥海之一冲合并刑冲我金星，且对方海王与我月金成相，且对方没有与我的月月月金日月日金的合拱六分，且对方金木不合我轴
        //			冲突指数/25*50%+10%
        if (isset($data1['planets'][4]['phase']['4-3']) && in_array($data1['planets'][4]['phase']['4-3']['phase_e'], [90, 180])
            && (isset($data1['planets'][8]['phase']['8-1']) || isset($data1['planets'][8]['phase']['8-3']))
            && (!isset($data1['planets'][1]['phase']['1-1']) || !in_array($data1['planets'][1]['phase']['1-1']['phase_e'], [0, 60, 120]))
            && (!isset($data1['planets'][1]['phase']['1-3']) || !in_array($data1['planets'][1]['phase']['1-3']['phase_e'], [0, 60, 120]))
            && (!isset($data1['planets'][0]['phase']['0-1']) || !in_array($data1['planets'][0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            && (!isset($data1['planets'][0]['phase']['0-3']) || !in_array($data1['planets'][0]['phase']['0-3']['phase_e'], [0, 60, 120]))
            && (!isset($data1['planets'][3]['phase']['3-' . ASC]) || !in_array($data1['planets'][3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][3]['phase']['3-' . MC]) || !in_array($data1['planets'][3]['phase']['3-' . MC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][5]['phase']['5-' . ASC]) || !in_array($data1['planets'][5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
            && (!isset($data1['planets'][5]['phase']['5-' . MC]) || !in_array($data1['planets'][5]['phase']['5-' . MC]['phase_e'], [0, 180]))
        )
        {
            $p4689_phase_4_0180 = [];
            foreach ([4, 6, 8, 9] as $p1)
            {
                if (isset($nata1['planets'][$p1]['phase'][$p1 . '-3']) && in_array($nata1['planets'][$p1]['phase'][$p1 . '-3']['phase_e'], [90, 180]))
                {
                    $p4689_phase_4_0180[] = $p1;
                }
            }
            $cond = false;
            if (!empty($p4689_phase_4_0180))
            {
                foreach ($p4689_phase_4_0180 as $p2)
                {
                    if (isset($data1['planets'][4]['phase']['4-' . $p2]) && in_array($data1['planets'][4]['phase']['4-' . $p2]['phase_e'], [0, 180]))
                    {
                        $cond = true;
                    }
                }
            }
            if ($cond === true)
            {
                $cond = $cond1_1 = $cond1_2 = $cond1_3 = false;
                // 你本命金星同时被火土冥海之二刑冲，或位于T三角顶点，或落在8/12宫被火土冥海之一合另一刑冲
                $p3_phase_4689_90180_num = 0;
                if (!empty($nata1['planets'][3]['phase']))
                {
                    foreach ($nata1['planets'][3]['phase'] as $phase)
                    {
                        if (in_array($phase['id'], [4, 6, 8, 9]) && in_array($phase['phase_e'], [90, 180]))
                        {
                            $p3_phase_4689_90180_num++;
                        }
                    }
                }
                if ($cond1_1 >= 2)
                {
                    $cond = true;
                }
                if ($cond === false)
                {
                    if (!empty($nata1['structure']['t_square']))
                    {
                        foreach ($nata1['structure']['t_square'] as $t_square)
                        {
                            if (isset($t_square[2]) && ($t_square[2] === 3 || $t_square[2] === 1))
                            {
                                $cond = true;
                                break;
                            }
                        }
                    }
                }
                if ($cond === false && in_array($nata1['planets'][3]['in_house_id'], [8, 12]))
                {
                    $pls = [4, 6, 8, 9];
                    foreach ($pls as $p1)
                    {
                        foreach ($pls as $p2)
                        {
                            if ($p1 != $p2
                                && ((isset($nata1['planets'][3]['phase']['3-' . $p1]) && in_array($nata1['planets'][3]['phase']['3-' . $p1]['phase_e'], [0]))
                                    && (isset($nata1['planets'][3]['phase']['3-' . $p2]) && in_array($nata1['planets'][3]['phase']['3-' . $p2]['phase_e'], [90, 180]))))
                            {
                                $cond = true;
                                break;
                            }
                        }
                    }
                }
                // 你本命月亮同时被火土冥海之二刑冲，或位于T三角顶点，或落在8/12宫被火土冥海之一合另一刑冲
                $p1_phase_4689_90180_num = 0;
                if (!empty($nata1['planets'][1]['phase']))
                {
                    foreach ($nata1['planets'][1]['phase'] as $phase)
                    {
                        if (in_array($phase['id'], [4, 6, 8, 9]) && in_array($phase['phase_e'], [90, 180]))
                        {
                            $p1_phase_4689_90180_num++;
                        }
                    }
                }
                if ($p1_phase_4689_90180_num >= 2)
                {
                    $cond = true;
                }
                if ($cond === false && in_array($nata1['planets'][1]['in_house_id'], [8, 12]))
                {
                    $pls = [4, 6, 8, 9];
                    foreach ($pls as $p1)
                    {
                        foreach ($pls as $p2)
                        {
                            if ($p1 != $p2
                                && ((isset($nata1['planets'][3]['phase']['3-' . $p1]) && in_array($nata1['planets'][3]['phase']['3-' . $p1]['phase_e'], [0]))
                                    && (isset($nata1['planets'][3]['phase']['3-' . $p2]) && in_array($nata1['planets'][3]['phase']['3-' . $p2]['phase_e'], [90, 180]))))
                            {
                                $cond = true;
                                break;
                            }
                        }
                    }
                }
                if ($cond === true)
                {
                    $result['keywords'][] = 35;
                    $result['scores'][] = $this->option['harmoniousConflict'][1] * 50 / 25 + 10;
                }
            }
        }
        //	一个转身 36
        //		ta与你，无任何日日、日月、日金、月月、月金、金金、金火、火火之间的相位，且日月金不合轴，且金不与上升拱六分
        //      （400-合盘指数）/100 * 25%
        if (
            !isset($data1['planets'][0]['phase']['0-0'])
            && !isset($data1['planets'][0]['phase']['0-1'])
            && !isset($data3['planets'][0]['phase']['0-1'])
            && !isset($data1['planets'][0]['phase']['0-3'])
            && !isset($data3['planets'][0]['phase']['0-3'])
            && !isset($data1['planets'][1]['phase']['1-1'])
            && !isset($data1['planets'][1]['phase']['1-3'])
            && !isset($data3['planets'][1]['phase']['1-3'])
            && !isset($data1['planets'][3]['phase']['3-3'])
            && !isset($data1['planets'][3]['phase']['3-4'])
            && !isset($data3['planets'][3]['phase']['3-4'])
            && !isset($data1['planets'][4]['phase']['4-4'])
            && !checkPhase([0, 1, 3], [ASC, MC], [0, 180], $data1)
            && !checkPhase([0, 1, 3], [ASC, MC], [0, 180], $data3)
            && !checkPhase([3], [ASC], [60, 120], $data1)
            && !checkPhase([3], [ASC], [60, 120], $data3)
        )
        {
            $result['keywords'][] = 36;
            $result['scores'][] = (400 - $this->data['synastryScore']) * 25 / 100;
        }
        // 火药桶 39
        //	1、如果你的本命存在火星合升降、日火、月火相位，则对方与你合盘符合以下条件之一：对方火星与你日月水之一成相，你的火星与对方日月水之一成相；对方火星与你日月水之二成相；对方火星与你日月水之一刑冲；对方火星合你轴点且与你日月金水火之一成相
        //	2、如果你的本命不存在火星合升降、日火、月火相位，则对方与你合盘符合以下条件之一：对方火星与你日月水之一刑冲，你的火星与对方日月水之一刑冲；对方火星与你日月水之二刑冲；对方火星与你日月水之一刑冲，土星也与你日月水之一刑冲；对方火星合你轴点且与你日月金水火之一刑冲
        //		（100-金星正数-太阳正数-月亮正数）*100%
        $cond = false;
        if (checkPhase([4], [ASC], [0, 180], $nata1) || isset($nata1['planets'][0]['phase']['0-4']) || isset($nata1['planets'][1]['phase']['1-4']))
        {
            // 对方火星与你日月水之一成相，你的火星与对方日月水之一成相；对方火星与你日月水之二成相；对方火星与你日月水之一刑冲；对方火星合你轴点且与你日月金水火之一成相
            if ((checkPhase([4], [0, 1, 2], [], $data1['planets']) && checkPhase([4], [0, 1, 2], [], $data3['planets']))
                || (checkPhase([4], [ASC, MC], [0, 180], $data1['planets']) && checkPhase([4], [0, 1, 2, 3, 4], [], $data1['planets'])))
            {
                $cond = true;
            }
            if ($cond === false)
            {
                $p4_phase_012_num = 0;
                $p4_phase_012_90180_num = 0;
                foreach ([0, 1, 2] as $p1)
                {
                    if (isset($data1['planets'][4]['phase']['4-' . $p1]))
                    {
                        $p4_phase_012_num++;
                        if (in_array($data1['planets'][4]['phase']['4-' . $p1]['phase_e'], [90, 180]))
                        {
                            $p4_phase_012_90180_num++;
                        }
                    }
                }
                if ($p4_phase_012_num >= 2 && $p4_phase_012_90180_num >= 1)
                {
                    $cond = true;
                }
            }
        } else
        {
            // 对方火星与你日月水之一刑冲，你的火星与对方日月水之一刑冲；对方火星与你日月水之二刑冲；对方火星与你日月水之一刑冲，土星也与你日月水之一刑冲；对方火星合你轴点且与你日月金水火之一刑冲
            if ((checkPhase([4], [0, 1, 2], [90, 180], $data1['planets']) && checkPhase([4], [0, 1, 2], [90, 180], $data3['planets']))
                || (checkPhase([4], [ASC, MC], [0, 180], $data1['planets']) && checkPhase([4], [0, 1, 2, 3, 4], [90, 180], $data1['planets'])))
            {
                $cond = true;
            }
            if ($cond === false)
            {
                $p4_phase_012_90180_num = 0;
                $p6_phase_012_90180_num = 0;
                foreach ([0, 1, 2] as $p1)
                {
                    if (isset($data1['planets'][4]['phase']['4-' . $p1]) && in_array($data1['planets'][4]['phase']['4-' . $p1]['phase_e'], [90, 180]))
                    {
                        $p4_phase_012_90180_num++;
                    }
                    if (isset($data1['planets'][6]['phase']['6-' . $p1]) && in_array($data1['planets'][6]['phase']['6-' . $p1]['phase_e'], [90, 180]))
                    {
                        $p6_phase_012_90180_num++;
                    }
                }
                if ($p4_phase_012_90180_num >= 2 || ($p4_phase_012_90180_num >= 1 && $p6_phase_012_90180_num >= 1))
                {
                    $cond = true;
                }
            }
        }
        if ($cond == true)
        {
            $result['keywords'][] = 39;
            $result['scores'][] = (100 - $venuScore1['good'] - $sunScore1['good'] - $moonScore1['good']);
        }

        // 启明星 40
        //  对方日月金木之一合你中天或落10宫，
        //  且该星与你的日月金木之一合拱六分（木木相位不算），
        //  且ta没有其它星体落你10宫或合天顶后与你的日月水火土形成刑冲，
        //  且ta火土海冥最多仅有一颗落你10宫且不合你天顶，
        //  且ta木星与你日月金水之一成相或合你轴点
        //      合盘指数/200*50%
        $h = 10;
        $p = MC;
        $pls1 = [0, 1, 3, 5];
        $pls2 = [4, 6, 8, 9];
        $cond1 = $cond2 = false;
        foreach ($pls1 as $p1)
        {
            if ($data1['planets'][$p1]['in_house_id'] == $h
                || (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p])
                    && $data1['planets'][$p1]['phase'][$p1 . '-' . $p]['phase_e'] == 0))
            {
                foreach ($pls1 as $p2)
                {
                    if (($p1 !== 5 || $p2 !== 5)
                        && isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                        && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                    {
                        $cond1 = true;
                    }
                }
            }
        }
        if ($cond1 === true)
        {
            for ($i = 0; $i < 10; $i++)
            {
                if ($cond2 === false && !in_array($i, $pls1))
                {
                    if ($data1['planets'][$i]['in_house_id'] == $h)
                    {
                        $cond2 = true;
                        break;
                    }
                    if ($cond2 === false && !empty($data1['planets'][$i]['phase']))
                    {
                        foreach ($data1['planets'][$i]['phase'] as $phase)
                        {
                            if ($cond2 === false &&
                                (in_array($phase['id'], [0, 1, 2, 4, 6]) && in_array($phase['phase_e'], [90, 180]))
                                && isset($data1['planets'][$i]['phase'][$i . '-' . $p])
                                && $data1['planets'][$i]['phase'][$i . '-' . $p]['phase_e'] == 0)
                            {
                                $cond2 = true;
                                break;
                            }
                        }
                    }
                }
            }
            // 且ta火土海冥最多仅有一颗落你10宫且不合你天顶，且ta木星与你日月金水之一成相或合你轴点
            if ($cond2 === false && (checkPhase([5], [0, 1, 2, 3], [], $data1['planets'])
                    || checkPhase([5], [ASC, MC], [0, 180], $data1)))
            {
                // 不合天顶落10宫行星数
                $in_house_10_num = 0;
                $in_house_10_phase_p_num = 0;
                foreach ($pls2 as $p3)
                {
                    if ($data1['planets'][$p3]['in_house_id'] == $h)
                    {
                        $in_house_10_num++;
                        if (isset($data1['planets'][$p3]['phase'][$p3 . '-' . $p])
                            && $data1['planets'][$p3]['phase'][$p3 . '-' . $p]['phase_e'] == 0)
                        {
                            $in_house_10_phase_p_num++;
                        }
                    }
                }
                if ($in_house_10_num <= 1 && $in_house_10_phase_p_num === 0)
                {
                    // 合盘指数/200*50%
                    $result['keywords'][] = 40;
                    $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
                }
            }
        }

        // 招财猫 41
        // 启明星中的10宫换为2宫
        //  对方日月金木之一落你2宫，
        //  且该星与你的日月金木之一合拱六分（木木相位不算），
        //  且ta没有其它星体落你2宫后与你的日月水火土形成刑冲，
        //  且ta火土海冥最多仅有一颗落你2宫，
        //  且ta木星或金星与你日月金水之一成相或合你轴点
        $h = 2;
        $p = MC;
        $pls1 = [0, 1, 3, 5];
        $pls2 = [4, 6, 8, 9];
        $cond1 = $cond2 = false;
        foreach ($pls1 as $p1)
        {
            if ($data1['planets'][$p1]['in_house_id'] == $h)
            {
                foreach ($pls1 as $p2)
                {
                    if (($p1 !== 5 || $p2 !== 5)
                        && isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2])
                        && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                    {
                        $cond1 = true;
                    }
                }
            }
        }
        if ($cond1 === true)
        {
            //  且ta没有其它星体落你2宫后与你的日月水火土形成刑冲，
            //  且ta火土海冥最多仅有一颗落你2宫，
            //  且ta木星或金星与你日月金水之一成相或合你轴点
            for ($i = 0; $i < 10; $i++)
            {
                if ($cond2 === false && !in_array($i, $pls1))
                {
                    if ($cond2 === false && $data1['planets'][$i]['in_house_id'] == $h && !empty($data1['planets'][$i]['phase']))
                    {
                        foreach ($data1['planets'][$i]['phase'] as $phase)
                        {
                            if ($cond2 === false
                                && (in_array($phase['id'], [0, 1, 2, 4, 6]) && in_array($phase['phase_e'], [90, 180])))
                            {
                                $cond2 = true;
                                break;
                            }
                        }
                    }
                }
            }
            // 且ta火土海冥最多仅有一颗落你2宫，且ta木星或金星与你日月金水之一成相或合你轴点
            if ($cond2 === false && (checkPhase([3, 5], [0, 1, 2, 3], [], $data1['planets']) || checkPhase([3, 5], [ASC, MC], [0, 180], $data1['planets'])))
            {
                // 落2宫行星数
                $in_house_2_num = 0;
                foreach ($pls2 as $p3)
                {
                    if ($data1['planets'][$p3]['in_house_id'] == $h)
                    {
                        $in_house_2_num++;
                    }
                }
                if ($in_house_2_num <= 1)
                {
                    // 合盘指数/200*50%
                    $result['keywords'][] = 41;
                    $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
                }
            }
        }
        // 心灵支点 42
        // 启明星中的10宫换为4宫，
        //  对方日月金木之一合你天底或落4宫，
        //  且该星与你的日月金木之一合拱六分（木木相位不算），
        //  且ta没有其它星体落你4宫或合天底后与你的日月水火土形成刑冲，
        //  且ta火土海冥最多仅有一颗落你4宫且不合你天底，
        //  且ta木星与你日月金水之一成相或合你轴点
        //  且对方月亮与我日月金之一合拱六分
        $h = 4;
        $p = MC;
        $pls1 = [0, 1, 3, 5];
        $pls2 = [4, 6, 8, 9];
        $cond1 = $cond2 = false;
        foreach ($pls1 as $p1)
        {
            if ($data1['planets'][$p1]['in_house_id'] == $h
                || (isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p]) && $data1['planets'][$p1]['phase'][$p1 . '-' . $p]['phase_e'] == 180))
            {
                foreach ($pls1 as $p2)
                {
                    if (($p1 !== 5 || $p2 !== 5) && isset($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]) && in_array($data1['planets'][$p1]['phase'][$p1 . '-' . $p2]['phase_e'], [0, 60, 120]))
                    {
                        $cond1 = true;
                        break;
                    }
                }
            }
        }
        if ($cond1 === true)
        {
            for ($i = 0; $i < 10; $i++)
            {
                if ($cond2 === false && !in_array($i, $pls1))
                {
                    if ($data1['planets'][$i]['in_house_id'] == $h)
                    {
                        $cond2 = true;
                        break;
                    }
                    if ($cond2 === false && !empty($data1['planets'][$i]['phase']))
                    {
                        foreach ($data1['planets'][$i]['phase'] as $phase)
                        {
                            if ($cond2 === false &&
                                (in_array($phase['id'], [0, 1, 2, 4, 6]) && in_array($phase['phase_e'], [90, 180]))
                                && isset($data1['planets'][$i]['phase'][$i . '-' . $p])
                                && $data1['planets'][$i]['phase'][$i . '-' . $p]['phase_e'] == 180)
                            {
                                $cond2 = true;
                                break;
                            }
                        }
                    }
                }
            }
            // 且ta火土海冥最多仅有一颗落你4宫且不合你天底，且ta木星与你日月金水之一成相或合你轴点
            if ($cond2 === false && (checkPhase([5], [0, 1, 2, 3], [], $data1['planets']) || checkPhase([5], [ASC, MC], [0, 180], $data1)))
            {
                // 不合天底落4宫行星数
                $in_house_4_num = 0;
                $in_house_4_phase_p_num = 0;
                foreach ($pls2 as $p3)
                {
                    if ($data1['planets'][$p3]['in_house_id'] == $h)
                    {
                        $in_house_4_num++;
                        if (isset($data1['planets'][$p3]['phase'][$p3 . '-' . $p]) && $data1['planets'][$p3]['phase'][$p3 . '-' . $p]['phase_e'] == 180)
                        {
                            $in_house_4_phase_p_num++;
                        }
                    }
                }
                // 且对方月亮与我日月金之一合拱六分
                if ($in_house_4_num <= 1 && $in_house_4_phase_p_num === 0 && checkPhase([1], [0, 1, 3], [0, 60, 120], $data1['planets']))
                {
                    // 合盘指数/200*50%
                    $result['keywords'][] = 42;
                    $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
                }
            }
        }
        // 春风玉露 43
        //	两人合盘无日火、日土刑冲；
        //  对方 日月金之一落我5宫，且与我日月金木合拱六分，且不与我任意星刑冲，且不与我土天海冥成相，且不与火星合相；
        //  我月亮与对方日月金木之一成非刑相，且无与日月金刑，无与火土合刑冲；
        //  我金星与对方日月金木之一成非刑相或合轴，且无与日月金刑，无与火土合刑冲；
        //  我与对方有金火或火火的合拱六分相；
        //		合盘指数/200*50%
        $is_p0_phase_90180 = checkPhase([0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [90, 180], $data1['planets']);
        $is_p1_phase_90180 = checkPhase([1], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [90, 180], $data1['planets']);
        $is_p3_phase_90180 = checkPhase([3], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [90, 180], $data1['planets']);
        if (
            !checkPhase([0], [4, 6], [90, 180], $data1['planets'])
            && !checkPhase([0], [4, 6], [90, 180], $data3['planets'])
            &&
            (
                ($data1['planets'][0]['in_house_id'] == 5
                    && checkPhase([0], [0, 1, 3, 5], [0, 60, 120], $data1['planets'])
                    && $is_p0_phase_90180 === false
                    && !checkPhase([0], [6, 7, 8, 9], [], $data1['planets'])
                    && !checkPhase([0], [4], [0], $data1['planets']))
                ||
                ($data1['planets'][1]['in_house_id'] == 5
                    && checkPhase([1], [0, 1, 3, 5], [0, 60, 120], $data1['planets'])
                    && $is_p1_phase_90180 === false
                    && !checkPhase([1], [6, 7, 8, 9], [], $data1['planets'])
                    && !checkPhase([1], [4], [0], $data1['planets']))
                ||
                ($data1['planets'][3]['in_house_id'] == 5
                    && checkPhase([3], [0, 1, 3, 5], [0, 60, 120], $data1['planets'])
                    && $is_p3_phase_90180 === false
                    && !checkPhase([3], [6, 7, 8, 9], [], $data1['planets'])
                    && !checkPhase([3], [4], [0], $data1['planets']))
            )
            &&
            (
                checkPhase([1], [0, 1, 3, 5], [0, 60, 120, 180], $data3['planets'])
                && !checkPhase([1], [0, 1, 3], [90], $data3['planets'])
                && !checkPhase([1], [4, 6], [0, 90, 180], $data3['planets'])
            )
            &&
            (
                (checkPhase([3], [0, 1, 3, 5], [0, 60, 120, 180], $data3['planets']) || checkPhase([3], [ASC, MC], [0, 180], $data3['planets']))
                && !checkPhase([3], [0, 1, 3], [90], $data3['planets'])
                && !checkPhase([3], [4, 6], [0, 90, 180], $data3['planets'])
            )
            && checkPhase([3, 4], [4], [0, 60, 120], $data3['planets'])
        )
        {
            $result['keywords'][] = 43;
            $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
        }
        // 姻缘锁 44
        //	对方日与我月成非刑相，对方月与我日成非刑相；
        //  对方日月金之一落我7宫或合我下降或与我南北交点合
        //      合盘指数/200*50%
        if (
            checkPhase([0], [1], [0, 60, 120, 180], $data1['planets'])
            && checkPhase([1], [0], [0, 60, 120, 180], $data1['planets'])
            &&
            (
                checkSignHouse([0, 1, 3], [7], $data1['planets'])
                || checkPhase([0, 1, 3], [ASC], [180], $data1['planets'])
                || checkPhase([0, 1, 3], [12], [0, 180], $data1['planets'])
            )
        )
        {
            $result['keywords'][] = 44;
            $result['scores'][] = $this->data['synastryScore'] * 50 / 200;
        }
        // 本命法宝 45
        //  合盘300分以上；对方金木合我轴或与我日月合拱六分，且我日月不与对方火土天海冥合刑冲，对方火土天海冥不合我轴
        //  合盘指数/300*100%
        if ($this->data['synastryScore'] >= 300
            && (checkPhase([3, 5], [ASC, MC], [0, 180], $data1['planets'])
                || checkPhase([3, 5], [0, 1], [0, 60, 120], $data1['planets']))
            && checkPhase([0, 1], [4, 6, 7, 8, 9], [0, 90, 180], $data3['planets'])
            && checkPhase([4, 6, 7, 8, 9], [ASC, MC], [0, 180], $data1['planets'])
        )
        {
            $result['keywords'][] = 45;
            $result['scores'][] = $this->data['synastryScore'] * 100 / 300;
        }

        // 其它各项都没有
        //	迷之缘分 22
        if (empty($result['keywords']))
        {
            $result['keywords'][] = 22;
            $result['scores'][] = 100;
        }

        return $result;
    }

    /**
     * 获取太阳数
     * @param array $data
     */
    protected function getSunScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 正值与负值
        $good = $bad = 0;
        // 对方太阳相位 以自己为底盘
        if (!empty($planets1[0]['phase']))
        {
            foreach ($planets1[0]['phase'] as $phase)
            {
                $pc = $this->getPhaseCoefficient($phase['phase_orb']);
                switch ($phase['id'])
                {
                    // 与我太阳
                    case 0:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我月亮
                    case 1:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 15 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我水星
                    case 2:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 2 * $pc;
                                break;
                            case 60:
                                $good += 1 * $pc;
                                break;
                            case 120:
                                $good += 1 * $pc;
                                break;
                            case 90:
                                $bad += 8 * $pc;
                                break;
                            case 180:
                                $good += 1 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我金星
                    case 3:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我火星
                    case 4:
                        $is_p0_phase_3_060120 = false;
                        if (isset($planets1[0]['phase']['0-3']) && in_array($planets1[0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                        {
                            $is_p0_phase_3_060120 = true;
                        }
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                if ($is_p0_phase_3_060120 === true) $good += 3 * $pc;
                                break;
                            case 60:
                                if ($is_p0_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 120:
                                if ($is_p0_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $good += 2 * 0.8 * $pc;
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我木星
                    case 5:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 5 * $pc;
                                break;
                            case 60:
                                $good += 4 * $pc;
                                break;
                            case 120:
                                $good += 4 * $pc;
                                break;
                            case 90:
                                $bad += 2 * $pc;
                                break;
                            case 180:
                                $good += 4 * 0.8 * $pc;
                                $bad += 1 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我土星
                    case 6:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天王星
                    case 7:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我海王星
                    case 8:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我冥王星
                    case 9:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我上升
                    case 17:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 180:
                                $good += 9 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天顶
                    case 20:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 180:
                                $good += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        $this->data['sun'][] = [
            'good' => $good,
            'bad' => $bad,
        ];
        return;
    }

    /**
     * 获取月亮数
     * @param array $data
     */
    protected function getMoonScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 正值与负值
        $good = $bad = 0;
        // 对方月亮相位 以自己为底盘
        if (!empty($planets1[1]['phase']))
        {
            foreach ($planets1[1]['phase'] as $phase)
            {
                $pc = $this->getPhaseCoefficient($phase['phase_orb']);
                switch ($phase['id'])
                {
                    // 与我太阳
                    case 0:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我月亮
                    case 1:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 15 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 6;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我水星
                    case 2:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 2 * $pc;
                                break;
                            case 60:
                                $good += 1 * $pc;
                                break;
                            case 120:
                                $good += 1 * $pc;
                                break;
                            case 90:
                                $bad += 8 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我金星
                    case 3:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我火星
                    case 4:
                        $is_p1_phase_3_060120 = false;
                        if (isset($planets1[1]['phase']['1-3']) && in_array($planets1[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                        {
                            $is_p1_phase_3_060120 = true;
                        }
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                if ($is_p1_phase_3_060120 === true) $good += 3 * $pc;
                                break;
                            case 60:
                                if ($is_p1_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 120:
                                if ($is_p1_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $good += 2 * 0.8 * $pc;
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我木星
                    case 5:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 5 * $pc;
                                break;
                            case 60:
                                $good += 4 * $pc;
                                break;
                            case 120:
                                $good += 4 * $pc;
                                break;
                            case 90:
                                $bad += 2 * $pc;
                                break;
                            case 180:
                                $good += 4 * 0.8 * $pc;
                                $bad += 1 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我土星
                    case 6:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天王星
                    case 7:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我海王星
                    case 8:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我冥王星
                    case 9:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我上升
                    case 17:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 180:
                                $good += 9 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天顶
                    case 20:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 180:
                                $good += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        $this->data['moon'][] = [
            'good' => $good,
            'bad' => $bad,
        ];
        return;
    }

    /**
     * 获取水星数（暂缺）
     * @param array $data
     */
    protected function getMercScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 正值与负值
        $good = $bad = 0;
        // 对方水星相位 以自己为底盘
        if (!empty($planets1[2]['phase']))
        {
            foreach ($planets1[2]['phase'] as $phase)
            {
                $pc = $this->getPhaseCoefficient($phase['phase_orb']);
                switch ($phase['id'])
                {
                    // 与我太阳
                    case 0:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我月亮
                    case 1:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 15 * $pc;
                                break;
                            case 180:
                                $bad += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我水星
                    case 2:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 2 * $pc;
                                break;
                            case 60:
                                $good += 1 * $pc;
                                break;
                            case 120:
                                $good += 1 * $pc;
                                break;
                            case 90:
                                $bad += 8 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我金星
                    case 3:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我火星
                    case 4:
                        $is_p1_phase_3_060120 = false;
                        if (isset($planets1[1]['phase']['1-3']) && in_array($planets1[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                        {
                            $is_p1_phase_3_060120 = true;
                        }
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                if ($is_p1_phase_3_060120 === true) $good += 3 * $pc;
                                break;
                            case 60:
                                if ($is_p1_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 120:
                                if ($is_p1_phase_3_060120 === true) $good += 2 * $pc;
                                break;
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我木星
                    case 5:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 5 * $pc;
                                break;
                            case 60:
                                $good += 4 * $pc;
                                break;
                            case 120:
                                $good += 4 * $pc;
                                break;
                            case 90:
                                $bad += 2 * $pc;
                                break;
                            case 180:
                                $bad += 1 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我土星
                    case 6:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天王星
                    case 7:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我海王星
                    case 8:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我冥王星
                    case 9:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我上升
                    case 17:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 180:
                                $good += 9 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天顶
                    case 20:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 180:
                                $good += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        $this->data['merc'][] = [
            'good' => $good,
            'bad' => $bad,
        ];
        return;
    }

    /**
     * 获取金星数
     * @param array $data
     */
    protected function getVenuScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 正值与负值
        $good = $bad = 0;
        // 对方金星相位 以自己为底盘
        if (!empty($planets1[3]['phase']))
        {
            foreach ($planets1[3]['phase'] as $phase)
            {
                $pc = $this->getPhaseCoefficient($phase['phase_orb']);
                switch ($phase['id'])
                {
                    // 与我太阳
                    case 0:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 4;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我月亮
                    case 1:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 15 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我水星
                    case 2:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 2 * $pc;
                                break;
                            case 60:
                                $good += 1 * $pc;
                                break;
                            case 120:
                                $good += 1 * $pc;
                                break;
                            case 90:
                                $bad += 8 * $pc;
                                break;
                            case 180:
                                $good += 1 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我金星
                    case 3:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 10 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我火星
                    case 4:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 60:
                                $good += 5 * $pc;
                                break;
                            case 120:
                                $good += 5 * $pc;
                                break;
                            case 90:
                                $bad += 7 * $pc;
                                break;
                            case 180:
                                $good += 5 * 0.8 * $pc;
                                $bad += 3 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我木星
                    case 5:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 5 * $pc;
                                break;
                            case 60:
                                $good += 4 * $pc;
                                break;
                            case 120:
                                $good += 4 * $pc;
                                break;
                            case 90:
                                $bad += 2 * $pc;
                                break;
                            case 180:
                                $good += 4 * 0.8 * $pc;
                                $bad += 1 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我土星
                    case 6:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $bad += 10 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天王星
                    case 7:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我海王星
                    case 8:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我冥王星
                    case 9:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我上升
                    case 17:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 180:
                                $good += 9 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天顶
                    case 20:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 180:
                                $good += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        $this->data['venu'][] = [
            'good' => $good,
            'bad' => $bad,
        ];
        return;
    }

    /**
     * 获取火星数
     * @param array $data
     */
    protected function getMarsScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 正值与负值
        $good = $bad = 0;
        // 对方火星相位 以自己为底盘
        if (!empty($planets1[4]['phase']))
        {
            foreach ($planets1[4]['phase'] as $phase)
            {
                $pc = $this->getPhaseCoefficient($phase['phase_orb']);
                switch ($phase['id'])
                {
                    // 与我太阳
                    case 0:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 60:
                                $good += 8 * $pc;
                                break;
                            case 120:
                                $good += 8 * $pc;
                                break;
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $good += 8 * 0.8 * $pc;
                                $bad += 12 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我月亮
                    case 1:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 10 * $pc;
                                break;
                            case 60:
                                $good += 8 * $pc;
                                break;
                            case 120:
                                $good += 8 * $pc;
                                break;
                            case 90:
                                $bad += 12 * $pc;
                                break;
                            case 180:
                                $good += 8 * 0.8 * $pc;
                                $bad += 12 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我水星
                    case 2:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 4 * $pc;
                                break;
                            case 180:
                                $bad += 4 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我金星
                    case 3:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 12 * $pc;
                                break;
                            case 60:
                                $good += 10 * $pc;
                                break;
                            case 120:
                                $good += 10 * $pc;
                                break;
                            case 90:
                                $bad += 6 * $pc;
                                break;
                            case 180:
                                $good += 10 * 0.8 * $pc;
                                $bad += 6;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我火星
                    case 4:
                        switch ($phase['phase_e'])
                        {
                            case 90:
                                $bad += 6 * $pc;
                                break;
                            case 180:
                                $bad += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我木星
                    case 5:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 8 * $pc;
                                break;
                            case 60:
                                $good += 6 * $pc;
                                break;
                            case 120:
                                $good += 6 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我土星

                    // 与我天王星

                    // 与我海王星

                    // 与我冥王星

                    // 与我上升
                    case 17:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 6 * $pc;
                                break;
                            case 180:
                                $good += 9 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    // 与我天顶
                    case 20:
                        switch ($phase['phase_e'])
                        {
                            case 0:
                                $good += 7 * $pc;
                                break;
                            case 180:
                                $good += 7 * $pc;
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        $this->data['mars'][] = [
            'good' => $good,
            'bad' => $bad,
        ];
        return;
    }

    /**
     * 获取冲断数
     * @param array $data
     */
    protected function getThrustScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 冲断数
        $score = 0;

        // 对方月冲我日
        if (isset($planets1[1]['phase']['1-0']) && $planets1[1]['phase']['1-0']['phase_e'] == 180)
        {
            $score += 10;
        }
        // 对方日冲我月
        if (isset($planets1[0]['phase']['0-1']) && $planets1[0]['phase']['0-1']['phase_e'] == 180)
        {
            $score += 10;
        }
        // 对方金冲我月
        if (isset($planets1[3]['phase']['3-1']) && $planets1[3]['phase']['3-1']['phase_e'] == 180)
        {
            $score += 10;
        }
        // 对方月冲我金
        if (isset($planets1[1]['phase']['1-3']) && $planets1[1]['phase']['1-3']['phase_e'] == 180)
        {
            $score += 10;
        }
        // 对方日冲我金
        if (isset($planets1[0]['phase']['0-3']) && $planets1[0]['phase']['0-3']['phase_e'] == 180)
        {
            $score += 8;
        }
        // 对方金冲我日
        if (isset($planets1[3]['phase']['3-0']) && $planets1[3]['phase']['3-0']['phase_e'] == 180)
        {
            $score += 8;
        }
        // 对方金冲我火
        if (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] == 180)
        {
            $score += 7;
        }
        // 对方金冲我金
        if (isset($planets1[3]['phase']['3-3']) && $planets1[3]['phase']['3-3']['phase_e'] == 180)
        {
            $score += 7;
        }
        // 对方火冲我金
        if (isset($planets1[4]['phase']['4-3']) && $planets1[4]['phase']['4-3']['phase_e'] == 180)
        {
            $score += 7;
        }
        $this->data['thrust'][] = $score;
        return;
    }

    /**
     * 获取粘合数
     */
    protected function getGlueScore()
    {
        // 检测星盘上的星群（仅限紧密、疏松两种），将星群最两侧的星体之中点定为星群中点，将星群中各星体力量之和计为星群力量
        //	各星体力量：日10月10金8水6火6木4土3天海冥2
        //	如果星群仅包含木土天海冥则视为1分
        $asterism1 = $this->option['data1'][1]['structure']['asterism'];
        // 紧密星群
        $asterism1_1 = $asterism1[1] ?? [];
        // 疏松星群
        $asterism1_2 = $asterism1[2] ?? [];

        $asterism2 = $this->option['data1'][0]['structure']['asterism'];
        // 紧密星群
        $asterism2_1 = $asterism2[1] ?? [];
        // 疏松星群
        $asterism2_2 = $asterism2[2] ?? [];
        // 各星体力量
        $base = [10, 10, 6, 8, 6, 4, 3, 2, 2, 2];
        // 双方星群力量
        $power = [0 => 0, 1 => 0];
        $midPoint1 = $midPoint2 = [];
        // 计算对方星群力量
        if (!empty($asterism1_1))
        {
            $not_only_56789 = false;
            $score = 0;
            foreach ($asterism1_1 as $k => $ast)
            {
                // 获取星群中点
                $midPoint1[] = $this->getAsterismMidPoint($this->option['data1'][1], $ast);
                foreach ($ast as $p)
                {
                    if (!in_array($p['id'], [5, 6, 7, 8, 9]))
                    {
                        $not_only_56789 = true;
                    }
                    $score += $base[$p['id']];
                }
            }
            $power[0] += $not_only_56789 ? $score : 1;
        }
        if (!empty($asterism1_2))
        {
            $not_only_56789 = false;
            $score = 0;
            foreach ($asterism1_2 as $k => $ast)
            {
                // 获取星群中点
                $midPoint1[] = $this->getAsterismMidPoint($this->option['data1'][1], $ast);
                foreach ($ast as $p)
                {
                    if (!in_array($p['id'], [5, 6, 7, 8, 9]))
                    {
                        $not_only_56789 = true;
                    }
                    $score += $base[$p['id']];
                }
            }
            $power[0] += $not_only_56789 ? $score : 1;
        }
        // 计算我方星群力量
        if (!empty($asterism2_1))
        {
            $not_only_56789 = false;
            $score = 0;
            foreach ($asterism2_1 as $k => $ast)
            {
                // 获取星群中点
                $midPoint2[] = $this->getAsterismMidPoint($this->option['data1'][0], $ast);
                foreach ($ast as $p)
                {
                    if (!in_array($p['id'], [5, 6, 7, 8, 9]))
                    {
                        $not_only_56789 = true;
                    }
                    $score += $base[$p['id']];
                }
            }
            $power[1] += $not_only_56789 ? $score : 1;
        }
        if (!empty($asterism2_2))
        {
            $not_only_56789 = false;
            $score = 0;
            foreach ($asterism2_2 as $k => $ast)
            {
                // 获取星群中点
                $midPoint2[] = $this->getAsterismMidPoint($this->option['data1'][0], $ast);
                foreach ($ast as $p)
                {
                    if (!in_array($p['id'], [5, 6, 7, 8, 9]))
                    {
                        $not_only_56789 = true;
                    }
                    $score += $base[$p['id']];
                }
            }
            $power[1] += $not_only_56789 ? $score : 1;
        }
        //	若对方星群中点与我星群中点成合冲拱六分相，则粘合数=双方星群力量之和*相位系数（不计算容许系数）
        //	若对方星群中点与我日月金之一成合冲拱六分相，则粘合数=对方星群力量与我星体力量之和*相位系数
        //		合1冲0.8拱六分0.7
        // 对方星群中点不为空
        $cond1 = false;
        $score1 = $score2_1 = $score2_2 = 0;
        $modules = [0 => 1, 60 => 0.7, 120 => 0.7, 180 => 0.8];
        if (!empty($midPoint1))
        {
            foreach ($midPoint1 as $deg1)
            {
                // 我方星群中点不为空
                if ($cond1 === false && !empty($midPoint2))
                {
                    foreach ($midPoint2 as $deg2)
                    {
                        $isPhaseDeg = $this->isPhase($deg1, $deg2, [0, 60, 120, 180]);

                        if ($cond1 === false && $isPhaseDeg !== false)
                        {
                            /** @var int $isPhaseDeg */
                            $score1 += ($power[0] + $power[1]) * $modules[$isPhaseDeg];
                            $cond1 = true;
                            continue;
                        }
                    }
                }
                foreach ([0, 1, 3] as $p)
                {
                    $isPhaseDeg = $this->isPhase($deg1, $this->option['data1'][0]['planets'][$p]['deg'], [0, 60, 120, 180]);

                    if ($isPhaseDeg !== false)
                    {
                        $score2_1 += ($power[1] + $base[$p]) * $modules[$isPhaseDeg];
                    }
                }
            }
        }

        // 我方星群中点不为空 即对方的对方
        if ($cond1 === false && !empty($midPoint2))
        {
            foreach ($midPoint2 as $deg1)
            {
                foreach ([0, 1, 3] as $p)
                {
                    $isPhaseDeg = $this->isPhase($deg1, $this->option['data1'][1]['planets'][$p]['deg'], [0, 60, 120, 180]);

                    if ($isPhaseDeg !== false)
                    {
                        $score2_2 += ($power[1] + $base[$p]) * $modules[$isPhaseDeg];
                    }
                }
            }
        }
        //	所有粘合数相加
        $this->data['glue'] = [
            0 => $score1 + $score2_1,
            1 => $score1 + $score2_2,
        ];
        // 双方星群中点
        $this->data['midPoint'] = [
            // 我方
            0 => $midPoint2,
            // 对方
            1 => $midPoint1,
        ];
        // 双方星群力量
        $this->data['power'] = [
            // 我方
            0 => $power[1],
            // 对方
            1 => $power[0],
        ];
        return;
    }

    /**
     * 获取宿命数
     * 即南北交点的关系 北交点与南交点
     * @param array $data 外盘数据
     */
    protected function getDestinyScore($data = [])
    {
        $planets1 = $data['planets'];
        // 初始化 宿命数
        $score = 0;
        // 对方日合我南北交点 10
        if (isset($planets1[0]['phase']['0-12']) && in_array($planets1[0]['phase']['0-12']['phase_e'], [0, 180]))
        {
            $score += 10;
        }
        // 对方月合我南北交点 10
        if (isset($planets1[1]['phase']['1-12']) && in_array($planets1[1]['phase']['1-12']['phase_e'], [0, 180]))
        {
            $score += 10;
        }
        // 对方金合我南北交点 8
        if (isset($planets1[3]['phase']['3-12']) && in_array($planets1[3]['phase']['3-12']['phase_e'], [0, 180]))
        {
            $score += 8;
        }
        // 对方火星合我南北交点 4
        if (isset($planets1[4]['phase']['4-12']) && in_array($planets1[4]['phase']['4-12']['phase_e'], [0, 180]))
        {
            $score += 4;
        }
        // 对方上升合我南北交点 10
        if (isset($planets1[17]['phase']['17-12']) && in_array($planets1[17]['phase']['17-12']['phase_e'], [0, 180]))
        {
            $score += 10;
        }
        // 对方天顶合我南北交点 6
        if (isset($planets1[20]['phase']['20-12']) && in_array($planets1[20]['phase']['20-12']['phase_e'], [0, 180]))
        {
            $score += 6;
        }
        // 对方日月金火拱我南北交点 6/6/4/2
        if (isset($planets1[0]['phase']['0-12']) && in_array($planets1[0]['phase']['0-12']['phase_e'], [60, 120]))
        {
            $score += 6;
        }
        if (isset($planets1[1]['phase']['1-12']) && in_array($planets1[1]['phase']['1-12']['phase_e'], [60, 120]))
        {
            $score += 6;
        }
        if (isset($planets1[3]['phase']['3-12']) && in_array($planets1[3]['phase']['3-12']['phase_e'], [60, 120]))
        {
            $score += 4;
        }
        if (isset($planets1[4]['phase']['4-12']) && in_array($planets1[4]['phase']['4-12']['phase_e'], [60, 120]))
        {
            $score += 2;
        }

        $this->data['destiny'][] = $score;
        return;
    }

    /**
     * 宫位激发数
     * 对方的星体落入我某宫
     *  如果该星体属于星群（紧密疏松，需星群中点在于该宫内），计算其星群力量
     *      各星体力量：日12、月12、水6、金8、火6、木4、土3、天海冥2
     *  如果该星体不属于星群，单独计算该星力量，但土天海冥不计
     * 该宫位被激发力量为所有星体之和
     * @param array $data
     */
    protected function getHouseScore($data = [])
    {
        $houses1 = $data['houses'];
        // 初始化
        $score = [];

        $asterism = $data['structure']['asterism'];
        // 紧密星群
        $asterism1 = $asterism[1] ?? [];
        // 疏松星群
        $asterism2 = $asterism[2] ?? [];

        // 各星体力量
        $base = [12, 12, 6, 8, 6, 4, 3, 2, 2, 2];
        // 12宫
        for ($i = 1; $i < 13; $i++)
        {
            // 初始化当前宫位激发数
            $score[$i] = 0;

            if (!empty($houses1[$i]['in_house_area_planet_info']))
            {
                // 遍历当前宫里的行星
                foreach ($houses1[$i]['in_house_area_planet_info'] as $p_in_house)
                {
                    $pid = $p_in_house['id'];

                    $is_p_in_asterism = false;

                    $asterismPower = 0;

                    if (!empty($asterism1))
                    {
                        foreach ($asterism1 as $ast1)
                        {
                            $asterismMidPoint = $this->getAsterismMidPoint($data, $ast1);
                            if ($is_p_in_asterism === false
                                && ($pid == $ast1[0]['id'] || $pid == $ast1[1]['id'] || $pid == $ast1[2]['id'])
                                && $this->isPointInHouse($data, $asterismMidPoint) == $i)
                            {
                                $asterismPower = $base[$ast1[0]['id']] + $base[$ast1[1]['id']] + $base[$ast1[2]['id']];
                                $is_p_in_asterism = true;
                                break;
                            }
                        }
                    }
                    if (!empty($asterism2))
                    {
                        foreach ($asterism2 as $ast2)
                        {
                            if ($is_p_in_asterism === false
                                && ($pid == $ast2[0]['id'] || $pid == $ast2[1]['id'] || $pid == $ast2[2]['id'])
                                && $ast2[1]['in_house_id'] == $i)
                            {
                                $asterismPower = $base[$ast2[0]['id']] + $base[$ast2[1]['id']] + $base[$ast2[2]['id']];
                                $is_p_in_asterism = true;
                                break;
                            }
                        }
                    }
                    if ($is_p_in_asterism === true)
                    {
                        $score[$i] += $asterismPower;
                    } elseif ($pid < 7)
                    {
                        $score[$i] += $base[$pid];
                    }
                }
            }
        }

        $this->data['house'][] = $score;

        return;
    }

    /**
     * 将计算出来的结果拆分成字符串
     * 格式如：9-50,12-30
     * keyword-score
     * @param array $data
     * @return string
     */
    protected function getFinalResult($data = [])
    {
        $str = '';

        if (isset($data['keywords']) && !empty($data['keywords']))
        {
            foreach ($data['keywords'] as $k => $d)
            {
                // 将负分过滤掉
                if($data['scores'][$k] > 0)
                {
                    $str .= ',' . $d . '-' . round($data['scores'][$k]);
                }
            }
        }

        return mb_substr($str, 1);
    }

    /**
     * 获取星群中点
     * @param array $data
     * @param array $asterism 星群数组
     * @return bool|float
     */
    protected function getAsterismMidPoint($data = [], $asterism = [])
    {
        if (!empty($data) && !empty($asterism))
        {
            foreach ($asterism as $p)
            {
                $arr[] = $data['planets'][$p['id']]['deg'];
            }
            // 升序排列
            sort($arr);

            $first = $arr[0];
            $last = $arr[count($arr) - 1];

            $midPoint = ($first + $last) / 2;

            return $midPoint;
        }
        return false;
    }

    /**
     * 判断点是否在该宫内
     * @param array $data 所有的行星数据
     * @param float $deg 该点的读书
     * @return bool
     */
    protected function isPointInHouse($data, $deg = null)
    {
        if (!empty($data) && $deg !== null && $deg !== false)
        {
            $houses = [];
            foreach ($data['houses'] as $i => $house)
            {
                $houses[$i] = $house['deg'];
            }
            return InWhichHouse($deg, $houses);
        }
        return false;
    }

    /**
     * 检测两个度数是否成相
     * @param null $deg1 度数1
     * @param null $deg2 度数2
     * @param array $phase 相位组
     * @param string $chart 所属盘，涉及到使用的默认相位容许度
     * @return int
     */
    protected function isPhase($deg1 = null, $deg2 = null, $phase = [], $chart = 'synastry')
    {
        if ($deg1 !== null && $deg1 !== false && $deg2 !== null && $deg2 !== false && !empty($phase))
        {
            $astroConfig = config('astroset.setting1')[$chart];

            $da = abs($deg1 - $deg2);
            if ($da > 180) $da = 360 - $da;

            foreach ($phase as $ph)
            {
                // 度数误差
                $asp_orb_deg = abs($da - $ph);
                // 相位容许
                $or_orb = $astroConfig['asp_orb_all'][$ph];

                if ($asp_orb_deg <= $or_orb)
                {
                    return $ph;
                }
            }
        }
        return false;
    }

    /**
     * 获取比较盘容许系数
     * @param null $orb
     * @return float
     */
    protected function getPhaseCoefficient($orb = null)
    {
        $phase_o = 0;

        if ($orb !== null)
        {
            if ($orb < 0.5) $phase_o = 1;
            elseif ($orb < 1.5) $phase_o = 0.9;
            elseif ($orb < 3) $phase_o = 0.85;
            elseif ($orb <= 5) $phase_o = 0.8;
            else $phase_o = 0.75;
        }
        return $phase_o;
    }
}